コード例 #1
0
        /// <summary>
        /// Gets the user status.
        /// </summary>
        /// <param name="logOnView">The log on view.</param>
        /// <returns></returns>

        public bool GetUserStatus(ILogOnView logOnView)
        {
            var userInfo = this.accountRepository.GetUserByEmail(logOnView.Email);

            if ((userInfo == null) || (userInfo.IsActive == false))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Signs the in.
        /// </summary>
        /// <param name="logonModel">The logon model.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">logonModel</exception>
        public bool SignIn(ILogOnView logonModel)
        {
            if (logonModel == null)
            {
                throw new ArgumentNullException(nameof(logonModel));
            }

            var userInfo = this.accountRepository.GetUserByEmail(logonModel.Email);

            if (userInfo == null)
            {
                return(false);
            }

            var decryptedValue = this.encryptionService.Decrypt(userInfo.Password);

            if (!logonModel.Password.Equals(decryptedValue))
            {
                return(false);
            }


            var userActionList = this.accountRepository.GetUserRoleActions(logonModel.Email).ToList();


            if (!userActionList.Any())
            {
                userActionList = new List <IUserRolesModel>();
            }

            var actionList = userActionList.Select(x => x.UserRolesDescription).ToArray();

            session.AddValueToSession(SessionKey.UserRoles, actionList[0]);
            this.SetUp(actionList[0], userInfo.UserRegistrationId);

            bool check = true;


            session.AddValueToSession(SessionKey.UserRoles, actionList);
            session.AddValueToSession(SessionKey.UserId, userInfo.UserRegistrationId);
            session.AddValueToSession(SessionKey.UserName, logonModel.Email);
            session.AddValueToSession(SessionKey.FullName, userInfo.FirstName);
            session.AddValueToSession(SessionKey.Email, userInfo.Email);
            session.AddValueToSession(SessionKey.UserIsAuthenticated, true);


            this.formsAuthentication.SignIn(logonModel.Email, logonModel.RememberMe);
            return(true);
        }
コード例 #3
0
 public static LogOnPresenter Create(ILogOnView view)
 {
     return(new LogOnPresenter(view));
 }
コード例 #4
0
 public LogOnPresenter(ILogOnView view)
 {
     ArgumentChecker.ThrowIfNull(view, "view");
     this.view = view;
 }
コード例 #5
0
        /// <summary>
        /// Signs the in.
        /// </summary>
        /// <param name="logonModel">The logon model.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">logonModel</exception>
        public bool SignIn(ILogOnView logonModel)
        {
            if (logonModel == null)
            {
                throw new ArgumentNullException("logonModel");
            }

            var userInfo = this.accountRepository.GetUserByUsername(logonModel.UserName);

            if (userInfo == null)
            {
                userInfo = this.accountRepository.GetUserByEmail(logonModel.UserName);
            }


            if (userInfo == null || (userInfo.IsLocked ?? false))
            {
                return(false);
            }

            var companyInfo = this.companyRepository.GetCompanyById(userInfo.CompanyId);

            var employeeInfo = this.employeeOnBoardRepository.GetEmployeeByEmail(userInfo.Email);

            var profileInfo = this.profileRepository.GetProfileByUserId(userInfo.UserId);


            var encriptedPwd =
                this.encryptionService.Encrypt(logonModel
                                               .Password); // for debugging....you dont get the same result when encrypting

            var decryptedValue = this.encryptionService.Decrypt(userInfo.Password);

            //:todo compare encripted or decripted password here
            if (!logonModel.Password.Equals(decryptedValue))
            //if (!logonModel.Password.Equals(userInfo.Password))
            {
                return(false);
            }


            //
            var userActionList = this.accountRepository.GetUserRoleActions(userInfo.Username).ToList();

            if (!userActionList.Any())
            {
                userActionList = new List <string>();
            }

            session.AddValueToSession(SessionKey.UserRoles, userActionList.ToArray());
            session.AddValueToSession(SessionKey.UserId, userInfo.UserId);
            session.AddValueToSession(SessionKey.UserName, logonModel.UserName);
            session.AddValueToSession(SessionKey.FullUserName, userInfo.FirstName + " " + userInfo.LastName);
            session.AddValueToSession(SessionKey.UserIsAuthenticated, true);
            session.AddValueToSession(SessionKey.CompanyId, 0);

            IDigitalFile profilePicture = null;

            if (employeeInfo != null)
            {
                session.AddValueToSession(SessionKey.EmployeeId, employeeInfo.EmployeeId);
                session.AddValueToSession(SessionKey.CompanyId, employeeInfo.CompanyId);
                if (employeeInfo != null)
                {
                    profilePicture = this.digitalFileRepository.GetDigitalFileDetail(employeeInfo.PhotoDigitalFileId ?? 0);
                }
            }

            if (profileInfo != null)
            {
                session.AddValueToSession(SessionKey.ProfileId, profileInfo.ProfileId);

                profilePicture = this.digitalFileRepository.GetDigitalFileDetail(profileInfo.PictureDigitalFileId);
            }


            if (profilePicture != null)
            {
                var imgSrc = "";
                var base64 = Convert.ToBase64String(profilePicture.TheDigitalFile);
                imgSrc = string.Format("data:{0};base64,{1}", profilePicture.ContentType, base64);
                session.AddValueToSession(SessionKey.ProfilePicture, imgSrc);
            }


            if (companyInfo != null)
            {
                var companyLogo = this.digitalFileRepository.GetDigitalFileDetail(companyInfo.LogoDigitalFileId ?? -1);

                var imgSrc = companyInfo.CompanyName;

                if (companyLogo != null)
                {
                    var base64 = Convert.ToBase64String(companyLogo.TheDigitalFile);
                    imgSrc = string.Format("data:{0};base64,{1}", companyLogo.ContentType, base64);
                }

                session.AddValueToSession(SessionKey.CompanyLogo, imgSrc);

                session.AddValueToSession(SessionKey.CompanyId, companyInfo.CompanyId);
            }

            this.formsAuthentication.SignIn(logonModel.UserName, logonModel.RememberMe);

            return(true);
        }
コード例 #6
0
 /// <summary>
 /// Gets the user by email.
 /// </summary>
 /// <param name="logOnView">The log on view.</param>
 /// <returns></returns>
 public IUserRegistration GetUserByEmail(ILogOnView logOnView)
 {
     return(this.accountRepository.GetUserByEmail(logOnView.Email));
 }
コード例 #7
0
        /// <summary>
        /// Creates the authentication page.
        /// </summary>
        /// <param name="registrationView">The registration view.</param>
        /// <param name="logOnView">The log on view.</param>
        /// <param name="changePasswordView">The change password view.</param>
        /// <returns></returns>
        public IHomeView CreateAuthenticationPage(IRegistrationView registrationView, ILogOnView logOnView, IChangePasswordView changePasswordView, string processingMessage)
        {
            var model = new HomeModelView
            {
                Registration      = registrationView,
                LogOn             = logOnView,
                ChangePassword    = changePasswordView,
                ProcessingMessage = processingMessage,
            };

            return(model);
        }