-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from traP-jp/signup
新規登録関連画面の実装
- Loading branch information
Showing
11 changed files
with
377 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_API_BASE_URL = http://localhost:4010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
interface ImportMetaEnv { | ||
readonly VITE_API_BASE_URL: string; | ||
} | ||
|
||
interface ImportMeta { | ||
readonly env: ImportMetaEnv; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<script setup lang="ts"> | ||
import { useRouter } from 'vue-router' | ||
const { | ||
disabled = false, | ||
app, | ||
mode | ||
} = defineProps<{ | ||
disabled?: boolean | ||
app: string | ||
mode: 'signup' | 'login' | ||
}>() | ||
const router = useRouter() | ||
async function onOAuthClick() { | ||
try { | ||
if (mode === 'signup') { | ||
if (app === 'Github') { | ||
const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/github-oauth2/params`) | ||
if (response.status === 200) { | ||
const responseJson = await response.json() | ||
alert(responseJson.url) | ||
router.push(responseJson.url) | ||
} else if (response.status === 500) { | ||
const responseJson = await response.json() | ||
alert('Internal Server Error: ' + responseJson.message) | ||
} else { | ||
alert(response.status) | ||
} | ||
} | ||
if (app === 'Google') { | ||
const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/google-oauth2/params`) | ||
if (response.status === 200) { | ||
const responseJson = await response.json() | ||
router.push(responseJson.url) | ||
} else if (response.status === 500) { | ||
const responseJson = await response.json() | ||
alert('Internal Server Error: ' + responseJson.message) | ||
} else { | ||
alert(response.status) | ||
} | ||
} | ||
if (app === 'traQ') { | ||
router.push('/_oauth/login?redirect=/') // TODO: Redirect to the correct URL | ||
} | ||
} | ||
} catch (error) { | ||
console.error('OAuth Error:', error) | ||
alert('OAuth Error:' + error) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<button | ||
:disabled="disabled" | ||
class="fontstyle-ui-control-strong inline-block space-x-2.5 rounded-lg border border-border-secondary px-3 py-2 text-text-primary enabled:hover:bg-background-secondary disabled:opacity-50" | ||
@click="onOAuthClick" | ||
> | ||
<span v-if="app === 'Github'" class="inline-block align-middle" | ||
><img src="" class="size-5" | ||
/></span> | ||
<span v-if="app === 'Google'" class="inline-block align-middle" | ||
><img src="" class="size-5" | ||
/></span> | ||
<span v-if="app === 'traQ'" class="inline-block align-middle" | ||
><img src="" class="size-5" | ||
/></span> | ||
<span class="inline-block align-middle">{{ app }} で新規登録</span> | ||
</button> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const usernameValidator = (username: string): boolean => { | ||
return /^[A-Za-z0-9_]{5,10}$/.test(username) | ||
} | ||
|
||
export const passwordValidator = (password: string): boolean => { | ||
const hasLetter = /[A-Za-z]/.test(password); | ||
const hasNumber = /[0-9]/.test(password); | ||
const hasSpecialChar = /[!@#$%^&*()_+\-={}[\]:;"'<>,.?/]/.test(password); | ||
const isValid = /^[A-Za-z0-9!@#$%^&*()_+\-={}[\]:;"'<>,.?/]{10,64}$/.test(password); | ||
return hasLetter && hasNumber && hasSpecialChar && isValid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.