Improve user error handling.

This commit is contained in:
Gucheng Wang
2021-12-12 19:59:55 +08:00
parent 96e2f286ee
commit f4265d015a
5 changed files with 16 additions and 5 deletions

View File

@ -162,10 +162,13 @@ func (c *ApiController) Signup() {
}
affected := object.AddUser(user)
if affected {
original.AddUserToOriginalDatabase(user)
if !affected {
c.ResponseError(fmt.Sprintf("Failed to create user, user information is invalid: %s", util.StructToJson(user)))
return
}
original.AddUserToOriginalDatabase(user)
if application.HasPromptPage() {
// The prompt page needs the user to be signed in
c.SetSessionUsername(user.GetId())