예제 #1
0
        /// <summary>
        /// Авторизоваться по номеру телефона
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <LoginResultModel> LoginByPhoneNumberAsync(LoginByPhoneNumberModel model)
        {
            var validation = ValidateModel(model);

            if (!validation.IsSucceeded)
            {
                return(new LoginResultModel(LoginErrorType.ModelNotValid, validation.Message));
            }

            var user = await UserSearcher.GetUserByPhoneNumberAsync(model.PhoneNumber);

            if (user == null)
            {
                return(UnSuccessfulLoginAttempt());
            }

            return(await LoginAsync(GetLoginModel(model, user.Email)));
        }
예제 #2
0
        public async Task <BaseApiResponse <LoginResultModel> > LoginByPhoneNumberAsync(LoginByPhoneNumberModel model, SignInManager <ApplicationUser> signInManager)
        {
            var validation = ValidateModel(model);

            if (!validation.IsSucceeded)
            {
                return(new BaseApiResponse <LoginResultModel>(validation));
            }

            var searcher = new UserSearcher(AmbientContext);

            var user = await searcher.GetUserByPhoneNumberAsync(model.PhoneNumber);

            if (user == null)
            {
                return(new BaseApiResponse <LoginResultModel>(false, "Пользователь не найден по указанному номеру телефона"));
            }

            return(await LoginAsync(new LoginModel(model, user.Email), signInManager));
        }
예제 #3
0
        public async Task <BaseApiResponse> UserForgotPasswordByPhoneHandlerAsync(ForgotPasswordModelByPhone model, UserManager <ApplicationUser> userManager)
        {
            var validation = ValidateModel(model);

            if (!validation.IsSucceeded)
            {
                return(validation);
            }

            if (IsAuthenticated)
            {
                return(new BaseApiResponse(false, "Вы авторизованы в системе"));
            }

            var searcher = new UserSearcher(AmbientContext);

            var user = await searcher.GetUserByPhoneNumberAsync(model.PhoneNumber);

            return(await UserForgotPasswordNotificateHandlerAsync(user.ToEntity(), userManager));
        }