public LoginRs Login(LoginRq request) { var response = new LoginRs(); var accountService = IocContainer.Resolve <IUserService>(); return(accountService.Login(request)); }
public LoginRs Login(LoginRq request) { var response = new LoginRs(); var user = _dbRepository.FirstOrDefault <User>(e => e.EmailAdress.Equals(request.Email) && e.Password.Equals(request.Password)); if (user == null) { response.IsSuccess = false; response.Message = "The email or password entered is incorrect."; return(response); } response.UserId = user.Id; return(response); }
private void ProcessLogin() { var loginRq = new LoginRq { username = LoginDetails.Username, passwordDigest = LoginDetails.PasswordHash, profile = LoginDetails.Profile, workstation = LoginDetails.Workstation, version = _appContext.Version(2), partnerCode = _appContext.Reg.getRegValue("PromoCode", true), loginGuest = LoginDetails.LoginGuest, }; LoginRs loginRs = null; try { loginRs = _appContext.ConnectionManager.Connection.Request <LoginRq, LoginRs>(loginRq); _appContext.CurrentUserManager.SetUser(loginRs.userElement, loginRs.shortCode); _appContext.RosterManager.RetrieveRoster(); if (loginRs.partnerElement != null) { _appContext.SettingsManager.Partner = new Partner() { Basename = loginRs.partnerElement.basename, LinkText = loginRs.partnerElement.linkText, Logo = Convert.FromBase64String(loginRs.partnerElement.logo), Name = loginRs.partnerElement.name, Text = loginRs.partnerElement.text, Website = loginRs.partnerElement.website }; } else { _appContext.SettingsManager.Partner = null; } } catch (MessageException <LoginRs> e) { if (!e.Response.loggedIn) { throw new LoginException("Failed to login, server responded with : " + e.Response.errorMessage, e.Response.error); } throw; } // Exception not thrown, login success, save details LoginDetails.Username = loginRs.userElement.user; _reg.Username = loginRs.userElement.user; _reg.PasswordHash = loginRq.loginGuest ? loginRs.guestSecretKey : LoginDetails.PasswordHash; _reg.Profile = LoginDetails.Profile = loginRs.profileId; LoginDetails.LoginGuest = false; IsLoggedIn = true; // Notify all threads waiting for login lock (LoginOccurredLock) { Monitor.PulseAll(LoginOccurredLock); } OnLoggedIn(); Logger.Info("Login success : " + _appContext.CurrentUserManager.CurrentUser.Username + "!" + _appContext.CurrentUserManager.ActiveShortCode + "@" + LoginDetails.Profile + "-" + LoginDetails.Workstation); // can fetch the team in the background ThreadPool.QueueUserWorkItem(state => { try { _appContext.TeamManager.RetrieveTeams(); } catch (Exception e) { Logger.Error("Failed to retrieve teams during login", e); } }); }