Пример #1
0
        public bool Login(string Username, string Password, out String returnMessage)
        {
            Password = Password.Encrypt(Username);
            Account account = _accountRepository.GetAccountByUsername(Username);

            if (account != null)
            {
                if (account.Password == Password)
                {
                    if (account.EmailVerified)
                    {
                        SetLogedIn(Username);
                        returnMessage = "Đăng nhập thành công";
                        if (!string.IsNullOrEmpty(_webContext.FriendshipRequest))
                        {
                            _friendService.CreateFriendFromFriendInvitation(new Guid(_webContext.FriendshipRequest), _userSession.CurrentUser);
                        }
                        return(true);
                    }
                    else
                    {
                        returnMessage = @"Bạn chưa xác thực email";
                        return(false);
                    }
                }
                else
                {
                    returnMessage = "Tên đăng nhập hoặc mật khẩu không đúng";
                    return(false);
                }
            }

            returnMessage = "We were unable to log you in with that information!";
            return(false);
        }
Пример #2
0
        public void Register(string Username, string Password, string Email, EnumObject Object,
                             string Captcha)
        {
            if (Captcha == _webContext.CaptchaImageText)
            {
                SPKTCore.Core.Domain.Account a =
                    new SPKTCore.Core.Domain.Account();
                a.Email       = Email;
                a.UserName    = Username;
                a.DisplayName = a.UserName;
                a.CreateDate  = DateTime.Now;
                a.Password    = Password.Encrypt(Username);
                a.UseAuthenticationService = false;

                if (_accountService.EmailInUse(Email))
                {
                    _view.ShowErrorMessage("Mail đã được sử dụng");
                }
                else if (_accountService.UsernameInUse(Username))
                {
                    _view.ShowErrorMessage("Tên đăng nhập này đã được sử dụng");
                }
                else
                {
                    string permission = Object.ToString();
                    _accountRepository.SaveAccount(a);
                    if (friendInvitation != null)
                    {
                        _friendService.CreateFriendFromFriendInvitation(new Guid(_webContext.FriendshipRequest), a);
                    }
                    _accountService.Register(a, permission);
                    _redirector.GoToAccountLoginPage();
                }
            }
            else
            {
                _view.ShowErrorMessage("CAPTCHA bạn nhập không đúng! Vui lòng nhập lại");
            }
        }