Example #1
0
 public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo)
 {
     return serverProvider.ResetPassword(resetPasswordInfo);
 }
Example #2
0
        public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo)
        {
            var emailOrMobile = resetPasswordInfo.EmailOrMobile.ToLower();
            var obj = repoUser.Query(o => o.Email == emailOrMobile || o.Mobile == emailOrMobile).FirstOrDefault();

            ServerResponse<Session> response = new ServerResponse<Session>();

            if (obj == null)
            {
                response.Status = ResponseStatus.Failed;
                response.Message = DAF.SSO.Resources.Locale(o => o.EmailOrMobileNotFound);
            }
            else
            {
                obj.Password = pwdEncryptor.Encrypt(resetPasswordInfo.NewPassword);
                if (repoUser.Update(obj))
                {
                    // reset successfully, sent user info.
                    ResetPasswordMessage msg = new ResetPasswordMessage()
                    {
                        Account = obj.Account,
                        FullName = obj.FullName,
                        NickName = obj.NickName,
                        NewPassword = resetPasswordInfo.NewPassword
                    };
                    if(resetPasswordInfo.EmailOrMobile == obj.Email)
                    {
                        msg.Email = obj.Email;
                    }
                    else if(resetPasswordInfo.EmailOrMobile == obj.Mobile)
                    {
                        msg.Mobile = obj.Mobile;
                    }
                    if(!string.IsNullOrEmpty(msg.Email) || !string.IsNullOrEmpty(msg.Mobile))
                    {
                        MessageManager.Publish<ResetPasswordMessage>(msg);
                    }

                    response.Status = ResponseStatus.Success;
                    response.Message = DAF.SSO.Resources.Locale(o => o.ChangePasswordSuccessfully);
                }
                else
                {
                    response.Status = ResponseStatus.Failed;
                    response.Message = DAF.Core.Resources.Locale(o => o.SaveFailure);
                }
            }
            return response;
        }
Example #3
0
        public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo)
        {
            Assert.IsNotNull(resetPasswordInfo);
            Assert.IsStringNotNullOrEmpty(resetPasswordInfo.EmailOrMobile);
            Assert.IsStringNotNullOrEmpty(resetPasswordInfo.NewPassword);

            IServerResponse response = serverProvider.ResetPassword(resetPasswordInfo);

            return response;
        }
Example #4
0
        public static ServerResponse ResetPassword(string emailOrMobile)
        {
            ServerResponse response = new ServerResponse();
            try
            {
                IRandomTextGenerator generator = IocInstance.Container.Resolve<IRandomTextGenerator>();
                var newPassword = generator.Generate(RandomChars, RandomLength);
                ResetPasswordInfo info = new ResetPasswordInfo()
                {
                    ClientId = CurrentClient.ClientId,
                    SessionId = HttpContext.Current.Session.SessionID,
                    DeviceId = HttpContext.Current.Request.UserHostAddress,
                    DeviceInfo = HttpContext.Current.Request.UserAgent,
                    EmailOrMobile = emailOrMobile,
                    NewPassword = newPassword
                };

                var cp = IocInstance.Container.Resolve<ISSOClientProvider>();
                var r = cp.ResetPassword(info);
                response.Status = r.Status;
                response.Message = r.Message;
            }
            catch (Exception ex)
            {
                response.Status = ResponseStatus.Exception;
                response.Message = ex.Message;
            }

            return response;
        }
Example #5
0
        public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo)
        {
            Assert.IsNotNull(resetPasswordInfo);
            Assert.IsStringNotNullOrEmpty(resetPasswordInfo.EmailOrMobile);
            Assert.IsStringNotNullOrEmpty(resetPasswordInfo.NewPassword);

            IServerResponse response = null;

            var chanel = CreateChannel();
            chanel.Call(p =>
            {
                response = p.ResetPassword(resetPasswordInfo);
            });

            return response;
        }