Exemplo n.º 1
0
        public IHttpActionResult ForgotPassword([FromBody] dynamic postBody)
        {
            string email       = postBody.email.Value.ToString();
            string redirectUrl = postBody.redirectUrl.value.ToString();

            #region validation
            // TODO: postBody validation
            user user = UsersDataService.GetUserByEmail(email);
            if (user == null)
            {
            }
            #endregion

            bool setStateResult = UsersDataService.SetupUserToForgotPasswordState(user);
            if (setStateResult)
            {
                // TODO: Implment SMTPService;
                // SMTPService.Send($"{ENV.END_POINT}/auth/reset-password?token={user.reset_password_token}&redirect-url={HttpUtility.UrlEncode(redirectUrl);}";
            }

            return(Json(new
            {
                data = CUSTOM_RESPONSE.STATUS.OK.ToString()
            }));
        }
Exemplo n.º 2
0
        public IHttpActionResult ForgotPassword([FromBody] dynamic postBody)
        {
            user newUser = UsersDataService.Register(postBody.email.Value, postBody.password.Value);

            return(Json(new
            {
                data = newUser
            }));
        }
Exemplo n.º 3
0
 public LoginViewModel()
 {
     viewId             = Guid.NewGuid();
     Title              = "Inicio de sesión";
     LoginCommand       = new RelayCommand(LoginCommandExec);
     securityService    = new SecurityService();
     webConsumerService = new WebConsumerService();
     usersDataService   = new UsersDataService();
 }
Exemplo n.º 4
0
        public IHttpActionResult Register([FromBody] dynamic postBody)
        {
            #region validation
            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match = regex.Match(postBody.email.Value);
            if (!match.Success)
            {
                return(ResponseMessage(
                           Request.CreateResponse(
                               HttpStatusCode.ExpectationFailed,
                               ERROR.INVALID_EMAIL
                               )));
            }

            if (postBody.password.Value.Length < 12)
            {
                return(ResponseMessage(
                           Request.CreateResponse(
                               HttpStatusCode.ExpectationFailed,
                               new ErrorObject(ERROR.PASSWORD_TOO_SHORT.ErrorCode, ERROR.PASSWORD_TOO_SHORT.ErrorMessage + ": Use a minimum password length of 12 or more characters if permitted")
                               )));
            }

            string specialCharacter                = "!@#$%&*?-_";
            char[] passwordCharacterList           = postBody.password.Value.ToCharArray();
            int    passwordCountOfSpeicalCharacter = passwordCharacterList.Where(x => specialCharacter.Contains(x)).Count();
            if (passwordCountOfSpeicalCharacter == 0)
            {
                return(ResponseMessage(
                           Request.CreateResponse(
                               HttpStatusCode.ExpectationFailed,
                               new ErrorObject(ERROR.PASSWORD_TOO_WEAK.ErrorCode, ERROR.PASSWORD_TOO_WEAK.ErrorMessage + $": password have to include one character of {specialCharacter}")
                               )));
            }
            #endregion

            user newUser = UsersDataService.Register(postBody.email.Value, postBody.password.Value);
            return(Json(new
            {
                data = newUser
            }));
        }
Exemplo n.º 5
0
        public virtual UsersDataService GetService()
        {
            var service = new UsersDataService(() => this.CreateContext(), this.passwordEncoderMock.Object);

            return(service);
        }
Exemplo n.º 6
0
 public UsersDataServiceTests()
 {
     this.usersRepository  = new InMemoryDeletableEntityRepository <User, string>();
     this.usersDataService = new UsersDataService(this.usersRepository);
 }