File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
pointercrate-user/src/auth Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 1+ use sqlx:: PgConnection ;
2+
3+ use crate :: auth:: legacy:: LegacyAuthenticatedUser ;
4+ use crate :: Result ;
5+
6+ use super :: { ValidatedGoogleCredentials } ;
7+
8+ impl LegacyAuthenticatedUser {
9+ pub async fn set_linked_google_account ( & mut self , creds : & ValidatedGoogleCredentials , connection : & mut PgConnection ) -> Result < ( ) > {
10+ sqlx:: query!(
11+ "UPDATE members SET google_account_id = $1 WHERE member_id = $2" ,
12+ creds. google_account_id( ) ,
13+ self . user( ) . id
14+ )
15+ . execute ( connection)
16+ . await ?;
17+
18+ Ok ( ( ) )
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -50,9 +50,6 @@ impl AuthenticatedUser<PasswordOrBrowser> {
5050 }
5151
5252 self . set_password ( password, connection) . await ?;
53-
54- // needed to invalidate existing access tokens
55- self . increment_generation_id ( connection) . await ?;
5653 }
5754
5855 self . into_user ( )
@@ -69,9 +66,12 @@ impl AuthenticatedUser<PasswordOrBrowser> {
6966
7067 async fn set_password ( & mut self , password : String , connection : & mut PgConnection ) -> Result < ( ) > {
7168 match & mut self . auth_type {
72- AuthenticationType :: Legacy ( legacy) => legacy. set_password ( password, connection) . await ,
73- _ => Err ( UserError :: NonLegacyAccount ) ,
69+ AuthenticationType :: Legacy ( legacy) => legacy. set_password ( password, connection) . await ? ,
70+ _ => return Err ( UserError :: NonLegacyAccount ) ,
7471 }
72+
73+ // needed to invalidate existing access tokens
74+ self . increment_generation_id ( connection) . await
7575 }
7676
7777 pub ( super ) async fn increment_generation_id ( & mut self , connection : & mut PgConnection ) -> Result < ( ) > {
You can’t perform that action at this time.
0 commit comments