Example #1
0
        private AuthenticationResult LogIn(string email, string password, bool stayLoggedInToday)
        {
            AuthenticationResult result = AuthenticationResult.Error(string.Empty);

            try
            {
                result = authenticationManager.LogIn(email, password, stayLoggedInToday);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, localizationManager.GetLocalizedString(ex.Message));
            }

            return(result);
        }
        public async Task <AuthenticationResult <string> > FetchUserKeyAsync(TUser user,
                                                                             CancellationToken cancellationToken)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            Handle(cancellationToken);
            var result = await UserStore.FetchUserKeyAsync(user, cancellationToken);

            if (result.RowsModified == 0)
            {
                return(AuthenticationResult <string> .Error());
            }
            return(AuthenticationResult <string> .Success(result.Result));
        }
        public async Task <AuthenticationResult <TUser> > FetchUserAsync(TUser user, CancellationToken canellationToken)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            Handle(canellationToken);
            var result = await UserStore.FetchUserAsync(user, canellationToken);

            if (!result.Succeeded || result.RowsModified != 1)
            {
                await Rollback(canellationToken, StoreTypes.UserStore);

                result = await EmailStore.FetchUser(user, canellationToken);

                if (result.RowsModified != 1)
                {
                    return(AuthenticationResult <string> .Error());
                }
            }
            return(AuthenticationResult <TUser> .Success(result.Result));
        }