Compare commits
No commits in common. "90cdcd16af2d3741247214f4e123825cc749a996" and "6d12ef9b94627527fca4119dda7f2b96d537ea48" have entirely different histories.
90cdcd16af
...
6d12ef9b94
|
@ -116,7 +116,7 @@ func (s *AccountServiceDefault) CreateAccount(email string, password string, ver
|
|||
}
|
||||
|
||||
if verifyEmail {
|
||||
err = s.SendEmailVerification(user.ID)
|
||||
err = s.SendEmailVerification(&user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -125,12 +125,7 @@ func (s *AccountServiceDefault) CreateAccount(email string, password string, ver
|
|||
return &user, nil
|
||||
}
|
||||
|
||||
func (s AccountServiceDefault) SendEmailVerification(userId uint) error {
|
||||
exists, user, err := s.AccountExists(userId)
|
||||
if !exists || err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *AccountServiceDefault) SendEmailVerification(user *models.User) error {
|
||||
token := GenerateSecurityToken()
|
||||
|
||||
var verification models.EmailVerification
|
||||
|
@ -139,7 +134,7 @@ func (s AccountServiceDefault) SendEmailVerification(userId uint) error {
|
|||
verification.Token = token
|
||||
verification.ExpiresAt = time.Now().Add(time.Hour)
|
||||
|
||||
err = s.db.Create(&verification).Error
|
||||
err := s.db.Create(&verification).Error
|
||||
if err != nil {
|
||||
return NewAccountError(ErrKeyDatabaseOperationFailed, err)
|
||||
}
|
||||
|
|
|
@ -169,16 +169,7 @@ func (a AccountAPI) verifyEmail(jc jape.Context) {
|
|||
if jc.Check("failed to verify email", err) != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (a AccountAPI) resendVerifyEmail(jc jape.Context) {
|
||||
user := middleware.GetUserFromContext(jc.Request.Context())
|
||||
|
||||
err := a.accounts.SendEmailVerification(user)
|
||||
|
||||
if jc.Check("failed to resend email verification", err) != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (a AccountAPI) otpGenerate(jc jape.Context) {
|
||||
|
@ -451,8 +442,7 @@ func (a *AccountAPI) Routes() (*httprouter.Router, error) {
|
|||
"POST /api/auth/logout": middleware.ApplyMiddlewares(a.logout, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
|
||||
// Account
|
||||
"POST /api/account/verify-email": middleware.ApplyMiddlewares(a.verifyEmail, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"POST /api/account/verify-email/resend": middleware.ApplyMiddlewares(a.resendVerifyEmail, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"POST /api/account/verify-email": middleware.ApplyMiddlewares(a.verifyEmail, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
"POST /api/account/otp/verify": middleware.ApplyMiddlewares(a.otpVerify, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"POST /api/account/otp/disable": middleware.ApplyMiddlewares(a.otpDisable, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"POST /api/account/password-reset/request": middleware.ApplyMiddlewares(a.passwordResetRequest, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
|
|
|
@ -54,12 +54,6 @@ paths:
|
|||
responses:
|
||||
'200':
|
||||
description: Email verified successfully
|
||||
/api/account/verify-email/resend:
|
||||
post:
|
||||
summary: Resend email verification
|
||||
responses:
|
||||
'200':
|
||||
description: Email verification resent successfully
|
||||
/api/auth/otp/generate:
|
||||
get:
|
||||
summary: Generate OTP for two-factor authentication
|
||||
|
|
Loading…
Reference in New Issue