mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 05:42:46 +00:00
Fix pg user already exists (#1076)
* Return newly created error if user already exists (#1002) Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Rename variable * Remove check for account and use returned error * Return ErrUserExists Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * State that CreateAccount will return err ErrUserExists if the user exists Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Also check sqlite for constraint error * Revert "Also check sqlite for constraint error" This reverts commit 7d310514 * Check for sqlite3 constraint error * Add documentation to CreateAccount * Move ErrUserExists to accounts package * Revert "Move ErrUserExists to accounts package" Import Cycle.. This reverts commit be3d4cda Co-authored-by: Kegsay <kegan@matrix.org>
This commit is contained in:
parent
cfc137652e
commit
895c8f03c0
7 changed files with 26 additions and 20 deletions
|
@ -830,15 +830,16 @@ func completeRegistration(
|
|||
|
||||
acc, err := accountDB.CreateAccount(ctx, username, password, appserviceID)
|
||||
if err != nil {
|
||||
if errors.Is(err, internal.ErrUserExists) { // user already exists
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.UserInUse("Desired user ID is already taken."),
|
||||
}
|
||||
}
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: jsonerror.Unknown("failed to create account: " + err.Error()),
|
||||
}
|
||||
} else if acc == nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.UserInUse("Desired user ID is already taken."),
|
||||
}
|
||||
}
|
||||
|
||||
// Increment prometheus counter for created users
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue