public ProcessResult LogInUser(LoginModel model, out UserModel userModel)
        {
            if (model.UserType == UserType.Lecturer)
                userModel = (UserModel)DataManager.Lecturer.LogInLecturer(model);
            else
                userModel = (UserModel)DataManager.Student.LogInStudent(model);

            if (userModel == null)
                return ProcessResults.InvalidEmailOrPassword;

            return ProcessResults.LoggedInSuccessfull;
        }
예제 #2
0
        public Lecturer LogInLecturer(LoginModel model)
        {
            var find = entities.Lecturers.ToList().FirstOrDefault(x =>
                (x.Login == model.LoginOrEmail ||
                x.Email == model.LoginOrEmail) &&
                model.Password == x.Password);

            if (find == null)
                return null;

            UpdateLastVisitDate(find);
            SaveChanges();
            return find;
        }
예제 #3
0
        public ActionResult ManageLogIn(string LoginOrEmail, string Password, string WhoAreU)
        {
            var loginModel = new LoginModel()
            {
                LoginOrEmail = LoginOrEmail,
                Password = Security.GetHashString(Password),
                UserType = WhoAreU.ToLower() == "студент" ? UserType.Student : UserType.Lecturer
            };

            UserModel user;
            ProcessResult result = DataManager.Authentification.LogInUser(loginModel, out user);
            if (result.Succeeded && user != null)
            {
                SetUser((UserModel)user, user.Password);
                return RedirectToAction("Index", "Home");
            }

            return RedirectToAction("LogIn",
                "User",
                new
                {
                    result = result.Id
                });
        }