--- title: email verification tags: v2 --- # Email Verification ## 需求 - 所有 user 都必須完成 email verify ### registered user - 登入後即跳出驗證 email 的頁面,沒驗證不能使用 ### new user - 輸入帳號密碼完後即創建帳號,要驗證 email 完才可繼續使用其他功能 ### SSO 登入 - 直接記錄成 已驗證 ## 如何驗證 - 寄出驗證 email 的信,信裡含有驗證 email 的 link,點擊後到前端頁面,前端會自動 call API,即完成驗證 ## 規則 - 10 分鐘內沒點擊 link 即失效 - 10 分鐘內 email 不能重新發送 - link 作法與忘記密碼相同,透過驗證後端產生的 code ## table email_verification ```db! { code: { type: String, required: true }, email: { type: String, required: true }, created_at: { type: Date, required: true }, updated_at: { type: Date, required: true } } ``` ## 規劃 - 在 `alpha_admin` 新增欄位 `verified` - 也要在 access_token 加入此欄位的值來判斷 user 是否完成 verify - collection: alpha_admin ```db! { verified: Boolean } ``` - access_token ``` { email: micky@fio.one, verified: false } ``` ### code - code 使用 jwt,藉此驗證是否過期 ### API POST `/api/v2/authentication/verify-email` ```json! { Input: { "username": "micky@fio.one" }, Output: { "code": 0, "message": "ok" } } ``` GET `/api/v2/authentication/verify-email/:code` ```json! { Input: {}, Output: { "code": 0, "message": "ok" } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up