-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): register with name (#2248)
* feat(ui): register with name * fix test * name required in registration * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
571b75c
commit 8c956b9
Showing
5 changed files
with
42 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ impl AuthenticationService for AuthenticationServiceImpl { | |
email: String, | ||
password: String, | ||
invitation_code: Option<String>, | ||
name: Option<String>, | ||
) -> Result<RegisterResponse> { | ||
let is_admin_initialized = self.is_admin_initialized().await?; | ||
if is_admin_initialized && is_demo_mode() { | ||
|
@@ -85,12 +86,17 @@ impl AuthenticationService for AuthenticationServiceImpl { | |
Some(pwd_hash), | ||
!is_admin_initialized, | ||
invitation.id, | ||
None, | ||
name.clone(), | ||
) | ||
.await? | ||
} else { | ||
self.db | ||
.create_user(email.clone(), Some(pwd_hash), !is_admin_initialized, None) | ||
.create_user( | ||
email.clone(), | ||
Some(pwd_hash), | ||
!is_admin_initialized, | ||
name.clone(), | ||
) | ||
.await? | ||
}; | ||
|
||
|
@@ -736,7 +742,12 @@ mod tests { | |
|
||
async fn register_admin_user(service: &AuthenticationServiceImpl) -> RegisterResponse { | ||
service | ||
.register(ADMIN_EMAIL.to_owned(), ADMIN_PASSWORD.to_owned(), None) | ||
.register( | ||
ADMIN_EMAIL.to_owned(), | ||
ADMIN_PASSWORD.to_owned(), | ||
None, | ||
None, | ||
) | ||
.await | ||
.unwrap() | ||
} | ||
|
@@ -791,7 +802,7 @@ mod tests { | |
// Admin initialized, registeration requires a invitation code; | ||
assert_matches!( | ||
service | ||
.register(email.to_owned(), password.to_owned(), None) | ||
.register(email.to_owned(), password.to_owned(), None, None) | ||
.await, | ||
Err(_) | ||
); | ||
|
@@ -802,7 +813,8 @@ mod tests { | |
.register( | ||
email.to_owned(), | ||
password.to_owned(), | ||
Some("abc".to_owned()) | ||
Some("abc".to_owned()), | ||
None | ||
) | ||
.await, | ||
Err(_) | ||
|
@@ -814,6 +826,7 @@ mod tests { | |
email.to_owned(), | ||
password.to_owned(), | ||
Some(invitation.code.clone()), | ||
None | ||
) | ||
.await | ||
.is_ok()); | ||
|
@@ -824,7 +837,8 @@ mod tests { | |
.register( | ||
email.to_owned(), | ||
password.to_owned(), | ||
Some(invitation.code.clone()) | ||
Some(invitation.code.clone()), | ||
None | ||
) | ||
.await, | ||
Err(_) | ||
|
@@ -1017,7 +1031,7 @@ mod tests { | |
.unwrap(); | ||
|
||
service | ||
.register("[email protected]".into(), "".into(), Some(code.code)) | ||
.register("[email protected]".into(), "".into(), Some(code.code), None) | ||
.await | ||
.unwrap(); | ||
|
||
|
@@ -1303,7 +1317,7 @@ mod tests { | |
|
||
// Create owner user. | ||
service | ||
.register("[email protected]".into(), "pass".into(), None) | ||
.register("[email protected]".into(), "pass".into(), None, None) | ||
.await | ||
.unwrap(); | ||
|
||
|