backend: fixed wrong error codes
This commit is contained in:
@@ -274,7 +274,11 @@ func (uc *UserController) RegisterUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
regData.User.RoleID = constants.Roles.Member
|
||||
if regData.User.Membership.SubscriptionModel.Name == constants.SupporterSubscriptionModelName {
|
||||
regData.User.RoleID = constants.Roles.Supporter
|
||||
} else {
|
||||
regData.User.RoleID = constants.Roles.Member
|
||||
}
|
||||
|
||||
// Register User
|
||||
id, token, err := uc.Service.RegisterUser(®Data.User)
|
||||
@@ -288,6 +292,16 @@ func (uc *UserController) RegisterUser(c *gin.Context) {
|
||||
}
|
||||
regData.User.ID = id
|
||||
|
||||
// if this is a supporter don't send mails and he never did give any consent. So stop here
|
||||
if regData.User.RoleID == constants.Roles.Supporter {
|
||||
|
||||
c.JSON(http.StatusCreated, gin.H{
|
||||
"message": "Supporter Registration successuful",
|
||||
"id": regData.User.ID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Register Consents
|
||||
var consents = [2]models.Consent{
|
||||
{
|
||||
|
||||
@@ -316,7 +316,7 @@ func testCurrentUserHandler(t *testing.T, loginEmail string, loginCookie http.Co
|
||||
setupCookie: func(req *http.Request) {},
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
expectedErrors: []map[string]string{
|
||||
{"field": "general", "key": "server.error.no_auth_token"},
|
||||
{"field": "server.general", "key": "server.error.no_auth_token"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -326,7 +326,7 @@ func testCurrentUserHandler(t *testing.T, loginEmail string, loginCookie http.Co
|
||||
},
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
expectedErrors: []map[string]string{
|
||||
{"field": "general", "key": "server.error.no_auth_token"},
|
||||
{"field": "server.general", "key": "server.error.no_auth_token"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -507,7 +507,7 @@ func testUpdateUser(t *testing.T, loginCookie http.Cookie, adminCookie http.Cook
|
||||
},
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
expectedErrors: []map[string]string{
|
||||
{"field": "general", "key": "server.error.no_auth_token"},
|
||||
{"field": "server.general", "key": "server.error.no_auth_token"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -948,7 +948,7 @@ func verifyMail(verificationURL string) error {
|
||||
router := gin.New()
|
||||
router.LoadHTMLGlob(filepath.Join(config.Templates.HTMLPath, "*"))
|
||||
|
||||
router.GET("/users/verify", Uc.VerifyMailHandler)
|
||||
router.GET("api/users/verify", Uc.VerifyMailHandler)
|
||||
wv := httptest.NewRecorder()
|
||||
cv, _ := gin.CreateTestContext(wv)
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user