feat: add integration tests for signup, login, reset_password, forgot_password, verify_email
This commit is contained in:
16
server/utils/create_session.go
Normal file
16
server/utils/create_session.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/authorizerdev/authorizer/server/db"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func CreateSession(userId string, c *gin.Context) {
|
||||
sessionData := db.Session{
|
||||
UserID: userId,
|
||||
UserAgent: GetUserAgent(c.Request),
|
||||
IP: GetIP(c.Request),
|
||||
}
|
||||
|
||||
db.Mgr.AddSession(sessionData)
|
||||
}
|
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
"github.com/authorizerdev/authorizer/server/enum"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -69,6 +70,13 @@ func IsValidRoles(userRoles []string, roles []string) bool {
|
||||
return valid
|
||||
}
|
||||
|
||||
func IsValidVerificationIdentifier(identifier string) bool {
|
||||
if identifier != enum.BasicAuthSignup.String() && identifier != enum.ForgotPassword.String() && identifier != enum.UpdateEmail.String() {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func IsStringArrayEqual(a, b []string) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
|
@@ -24,7 +24,6 @@ func CreateVerificationToken(email string, tokenType string) (string, error) {
|
||||
|
||||
t.Claims = &CustomClaim{
|
||||
&jwt.StandardClaims{
|
||||
|
||||
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
|
||||
},
|
||||
tokenType,
|
||||
|
Reference in New Issue
Block a user