public LoginResponse Login(string email, string password) { BaseEmailValidation(email); EmailValidation(email); BasePasswordValidation(password); var user = GetForLoginByEmail(email); if (user == null || user.Password != GetHashedPassword(password, user.Email, user.CreationDate)) { throw new BusinessException("Invalid credentials."); } bool hasInvestment = GetUserHasInvestment(user); ActionBusiness.InsertNewLogin(user.Id, null, null); return(new LoginResponse() { Id = user.Id, Email = user.Email, PendingConfirmation = !user.ConfirmationDate.HasValue, IsAdvisor = IsValidAdvisor(user), AdvisorName = UserBusiness.GetAdvisorName(user), ProfileUrlGuid = UserBusiness.GetProfileUrlGuid(user), HasInvestment = hasInvestment }); }
private LoginResponse SocialRegister(string email, bool requestedToBeAdvisor, SocialNetworkType socialNetworkType) { var user = SetNewUser(email, null, null, true); Data.Insert(user); ActionBusiness.InsertNewLogin(user.Id, null, socialNetworkType); return(new LoginResponse() { Id = user.Id, Email = user.Email, HasInvestment = false, PendingConfirmation = false, IsAdvisor = false, RequestedToBeAdvisor = requestedToBeAdvisor }); }
private LoginResponse SocialLogin(User user, SocialNetworkType socialNetworkType) { if (!user.ConfirmationDate.HasValue) { user.ConfirmationDate = Data.GetDateTimeNow(); Data.Update(user); } bool hasInvestment = GetUserHasInvestment(user); ActionBusiness.InsertNewLogin(user.Id, null, socialNetworkType); return(new LoginResponse() { Id = user.Id, Email = user.Email, PendingConfirmation = !user.ConfirmationDate.HasValue, IsAdvisor = IsValidAdvisor(user), AdvisorName = UserBusiness.GetAdvisorName(user), ProfileUrlGuid = UserBusiness.GetProfileUrlGuid(user), HasInvestment = hasInvestment }); }