public static async Task PopulateSessionAsync(this IAuthSession session, IUserAuth userAuth, IAuthRepositoryAsync authRepo = null, CancellationToken token = default) { if (userAuth == null) { return; } PopulateSessionInternal(session, userAuth); var hadUserAuthId = session.UserAuthId != null; if (hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = await authRepo.GetAuthTokensAsync(session.UserAuthId, token).ConfigAwait(); } //session.UserAuthId could be populated in populator if (!hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = await authRepo.GetAuthTokensAsync(session.UserAuthId, token).ConfigAwait(); } var existingPopulator = AutoMappingUtils.GetPopulator(typeof(IAuthSession), typeof(IUserAuth)); existingPopulator?.Invoke(session, userAuth); }
public static void PopulateSession(this IAuthSession session, IUserAuth userAuth, IAuthRepository authRepo = null) { if (userAuth == null) { return; } PopulateSessionInternal(session, userAuth); var hadUserAuthId = session.UserAuthId != null; if (hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = authRepo.GetAuthTokens(session.UserAuthId); } //session.UserAuthId could be populated in populator if (!hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = authRepo.GetAuthTokens(session.UserAuthId); } var existingPopulator = AutoMappingUtils.GetPopulator(typeof(IAuthSession), typeof(IUserAuth)); existingPopulator?.Invoke(session, userAuth); }
public static void PopulateSession(this IAuthSession session, IUserAuth userAuth, IAuthRepository authRepo = null) { if (userAuth == null) { return; } var holdSessionId = session.Id; session.PopulateWith(userAuth); session.Id = holdSessionId; session.UserAuthId ??= (userAuth.Id != default ? userAuth.Id.ToString(CultureInfo.InvariantCulture) : null); session.IsAuthenticated = true; var hadUserAuthId = session.UserAuthId != null; if (hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = authRepo.GetAuthTokens(session.UserAuthId); } var existingPopulator = AutoMappingUtils.GetPopulator(typeof(IAuthSession), typeof(IUserAuth)); existingPopulator?.Invoke(session, userAuth); //session.UserAuthId could be populated in populator if (!hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = authRepo.GetAuthTokens(session.UserAuthId); } }
public static async Task PopulateSessionAsync(this IAuthSession session, IUserAuth userAuth, IAuthRepositoryAsync authRepo = null, CancellationToken token = default) { if (userAuth == null) { return; } var holdSessionId = session.Id; session.PopulateWith(userAuth); session.Id = holdSessionId; session.UserAuthId ??= (userAuth.Id != default ? userAuth.Id.ToString(CultureInfo.InvariantCulture) : null); if (userAuth.Meta != null) { session.PopulateFromMap(userAuth.Meta); } session.IsAuthenticated = true; var hadUserAuthId = session.UserAuthId != null; if (hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = await authRepo.GetAuthTokensAsync(session.UserAuthId, token).ConfigAwait(); } var existingPopulator = AutoMappingUtils.GetPopulator(typeof(IAuthSession), typeof(IUserAuth)); existingPopulator?.Invoke(session, userAuth); //session.UserAuthId could be populated in populator if (!hadUserAuthId && authRepo != null) { session.ProviderOAuthAccess = await authRepo.GetAuthTokensAsync(session.UserAuthId, token).ConfigAwait(); } }
void RegisterPopulator() { var existingPopulator = AutoMappingUtils.GetPopulator(typeof(IAuthSession), typeof(IUserAuth)); AutoMapping.RegisterPopulator((IAuthSession session, IUserAuth userAuth) => { existingPopulator?.Invoke(session, userAuth); UpdateSessionKey(session, userAuth); }); }
public static void PopulateSession(this IAuthSession session, IUserAuth userAuth, List <IAuthTokens> authTokens = null) { if (userAuth == null) { return; } var holdSessionId = session.Id; session.PopulateWith(userAuth); session.Id = holdSessionId; session.UserAuthId = session.UserAuthId ?? userAuth.Id.ToString(CultureInfo.InvariantCulture); session.IsAuthenticated = true; if (authTokens != null) { session.ProviderOAuthAccess = authTokens; } var existingPopulator = AutoMappingUtils.GetPopulator(typeof(IAuthSession), typeof(IUserAuth)); existingPopulator?.Invoke(session, userAuth); }