diff options
| author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-09 10:20:31 +0530 | 
|---|---|---|
| committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-09 10:20:31 +0530 | 
| commit | 8f2180401fd05ba63633d9559dc156f5ca1573ba (patch) | |
| tree | f3d2f59b04d5940bc5028904d6ce9d551aace86a /auth | |
| parent | cba9f19ba50c60576a5961e89c24caefca52d740 (diff) | |
logging in with either username or email
Diffstat (limited to 'auth')
| -rw-r--r-- | auth/auth.go | 6 | ||||
| -rw-r--r-- | auth/controller.go | 10 | 
2 files changed, 13 insertions, 3 deletions
diff --git a/auth/auth.go b/auth/auth.go index 6797c91..ae2db9b 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -25,3 +25,9 @@ type AuthClaims struct {  	jwt.RegisteredClaims  	UserID uint `json:"userid"`  } + +type LoginReq struct { +	AccountName string +	Method      string +	Password    string +} diff --git a/auth/controller.go b/auth/controller.go index 277a85a..1e6f7fe 100644 --- a/auth/controller.go +++ b/auth/controller.go @@ -25,6 +25,7 @@ import (  	"vidhukant.com/openbills/user"  	"net/http"  	"time" +	"fmt"  )  var ( @@ -68,12 +69,15 @@ func handleSignUp (ctx *gin.Context) {  }  func handleSignIn (ctx *gin.Context) { -	var u user.User -	ctx.Bind(&u) +	var req LoginReq +	ctx.Bind(&req) + +	fmt.Println(req)  	var err error +	var u user.User -	err = user.CheckPassword(u.ID, u.Password) +	err = user.CheckPassword(&u, req.AccountName, req.Method, req.Password)  	if err != nil {  		// TODO: handle potential errors  		ctx.Error(err)  |