66
77namespace CodeWorks . Auth . Services ;
88
9- public interface IOAuthService < TIdentity > where TIdentity : IAccountIdentity , new ( )
10- {
11- Task < AuthResult < TIdentity > > HandleOAuthCallbackAsync ( ExternalLoginInfo loginInfo ) ;
12- Task < string > GenerateOAuthStateAsync ( string provider , string ? returnUrl = null ) ;
13- Task < bool > ValidateOAuthStateAsync ( string state ) ;
14- }
15-
169public class OAuthService < TIdentity > : IOAuthService < TIdentity > where TIdentity : class , IAccountIdentity , new ( )
1710{
18- private readonly IUserStore < TIdentity > _userStore ;
11+ private readonly IAccountIdentityStore < TIdentity > _userStore ;
1912 private readonly IAuthService < TIdentity > _authService ;
2013 private readonly IOAuthStateStore _oauthStateStore ;
2114 private readonly ILogger < OAuthService < TIdentity > > _logger ;
2215
2316 public OAuthService (
24- IUserStore < TIdentity > userStore ,
17+ IAccountIdentityStore < TIdentity > userStore ,
2518 IAuthService < TIdentity > authService ,
2619 IOAuthStateStore oauthStateStore ,
2720 ILogger < OAuthService < TIdentity > > logger )
@@ -123,7 +116,7 @@ public async Task<AuthResult<TIdentity>> HandleOAuthCallbackAsync(ExternalLoginI
123116 existingUser . ProfilePictureUrl = picture ;
124117 }
125118
126- await _userStore . UpdateAsync ( existingUser ) ;
119+ await _userStore . SaveAsync ( existingUser ) ;
127120
128121 var token = _authService . GenerateAuthToken ( existingUser ) ;
129122 return AuthResult < TIdentity > . Success ( existingUser , token . Token ! ) ;
@@ -177,15 +170,3 @@ public Task<bool> ValidateOAuthStateAsync(string state)
177170 } ) ;
178171 }
179172}
180-
181-
182- // Add to existing IUserStore interface
183- public interface IUserStore < TUser > where TUser : IAccountIdentity
184- {
185- Task < TUser > FindByEmailAsync ( string email ) ;
186- Task < TUser > FindByIdAsync ( string id ) ;
187- Task < TUser > FindByProviderAsync ( string provider , string providerId ) ;
188- Task CreateAsync ( TUser user ) ;
189- Task UpdateAsync ( TUser user ) ;
190- Task DeleteAsync ( string id ) ;
191- }
0 commit comments