Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited3e66a

Browse files
committed
updated
1 parente011847 commited3e66a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

‎controllers/auth.controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func NewAuthController(DB *gorm.DB) AuthController {
2121
returnAuthController{DB}
2222
}
2323

24-
// SignUp User
24+
//[...]SignUp User
2525
func (ac*AuthController)SignUpUser(ctx*gin.Context) {
2626
varpayload*models.SignUpInput
2727

@@ -91,6 +91,7 @@ func (ac *AuthController) SignUpUser(ctx *gin.Context) {
9191
ctx.JSON(http.StatusCreated, gin.H{"status":"success","message":message})
9292
}
9393

94+
// [...] SignIn User
9495
func (ac*AuthController)SignInUser(ctx*gin.Context) {
9596
varpayload*models.SignInInput
9697

@@ -106,6 +107,11 @@ func (ac *AuthController) SignInUser(ctx *gin.Context) {
106107
return
107108
}
108109

110+
if!user.Verified {
111+
ctx.JSON(http.StatusForbidden, gin.H{"status":"fail","message":"Please verify your email"})
112+
return
113+
}
114+
109115
iferr:=utils.VerifyPassword(user.Password,payload.Password);err!=nil {
110116
ctx.JSON(http.StatusBadRequest, gin.H{"status":"fail","message":"Invalid email or Password"})
111117
return
@@ -125,11 +131,13 @@ func (ac *AuthController) SignInUser(ctx *gin.Context) {
125131
ctx.JSON(http.StatusOK, gin.H{"status":"success","token":token})
126132
}
127133

134+
// [...] SignOut User
128135
func (ac*AuthController)LogoutUser(ctx*gin.Context) {
129136
ctx.SetCookie("token","",-1,"/","localhost",false,true)
130137
ctx.JSON(http.StatusOK, gin.H{"status":"success"})
131138
}
132139

140+
// [...] Verify Email
133141
func (ac*AuthController)VerifyEmail(ctx*gin.Context) {
134142

135143
code:=ctx.Params.ByName("verificationCode")

‎readMe.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33
###1. How to Setup Golang GORM RESTful API Project with Postgres
44

55
[How to Setup Golang GORM RESTful API Project with Postgres](https://codevoweb.com/setup-golang-gorm-restful-api-project-with-postgres/)
6+
7+
###2. API with Golang + GORM + PostgreSQL: Access & Refresh Tokens
8+
9+
[API with Golang + GORM + PostgreSQL: Access & Refresh Tokens](https://codevoweb.com/golang-gorm-postgresql-user-registration-with-refresh-tokens)
10+
11+
###3. Golang and GORM - User Registration and Email Verification
12+
13+
[Golang and GORM - User Registration and Email Verification](https://codevoweb.com/golang-and-gorm-user-registration-email-verification)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp