public ActionResult Giris(string username, string password, User user) { LoginValidation loginValidation = new LoginValidation(); ValidationResult result = loginValidation.Validate(user); if (result.IsValid == false) { foreach (var error in result.Errors) { ModelState.AddModelError(error.PropertyName, error.ErrorMessage); } return(View(user)); } else { var loginuser = _userService.CheckUser(username, password); if (loginuser != null) { AuthenticationHelper.CreateAuthCookie(loginuser.UserId, loginuser.Username, loginuser.Email, DateTime.Now.AddDays(15), _userService.GetUserRole(username).Select(x => x.RoleName).ToArray(), false, loginuser.FirstName, loginuser.LastName); return(RedirectToAction("Index", "AnaSayfa")); } ViewBag.LoginError = "Kullanıcı adı veya şifre yanlış!"; return(View()); } }
// GET: Account // http://localhost:50601/account/login?username=fatih&password=12345 public string Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is authenticated!"); } return("User is Not authenticated!"); //AuthenticationHelper.CreateAuthCookie( // new Guid(), // "fatihertugral", // "*****@*****.**", // DateTime.Now.AddDays(15), // new[] { "Admin" }, // false, // "Fatih", // "Ertugral"); //return "User is authenticated!"; }
public ActionResult VerifyAccount(string id) { bool Status = false; if (Guid.TryParse(id, out Guid go)) { if (All.MS().CheckNullable(x => x.ActivationCode == go)) { var Account = All.MS().GetFirst(x => x.ActivationCode == go); All.MS().VerifyAccount(Account); var role = All.MRS().GetUserRole(Account.RoleID); AuthenticationHelper.CreateAuthCookie(Account.MemberID, Account.Name, Account.Email, Account.Password, role.RoleName); Status = true; } else { ViewBag.Message = "無效的操作。Invalid Request."; } } else { ViewBag.Message = "無效的操作。Invalid Request."; } ViewBag.Status = Status; return(View()); }
public IDataResult <User> Login(UserForLoginDto userForLoginDto) { var user = GetByUserNameAndPassword(userForLoginDto.UserName).Data; if (user == null) { return(new ErrorDataResult <User>("Kullanıcı yok")); } using (var hmac = new System.Security.Cryptography.HMACSHA512(user.PasswordSalt)) { var computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(userForLoginDto.Password)); for (int i = 0; i < computedHash.Length; i++) { if (computedHash[i] != user.PasswordHash[i]) { return(new ErrorDataResult <User>("Şifreler Eşleşmiyor")); } } AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddSeconds(10), GetUserRoles(user).Data.Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return(new SuccessDataResult <User>(user)); } }
public async Task <ActionResult> LoginPage(LoginUserModel loginUserModel) { if (ModelState.IsValid) { TokenContent rest = await _loginApiService.Authenticate(ApiUrl + "token", loginUserModel); if (rest.access_token != null) { InstructorDto ınstructorDto = await _userApiService.Get(rest.access_token, ApiUrl + "api/User", loginUserModel); string[] roles = new string[ınstructorDto.Roles.Count]; for (int i = 0; i < ınstructorDto.Roles.Count; i++) { ınstructorDto.Roles.ForEach(x => roles[i] = x.Name.ToString()); } AuthenticationHelper.CreateAuthCookie(ınstructorDto.Id, ınstructorDto.UserName, DateTime.Now.AddDays(1), roles, false, ınstructorDto.FirstName, ınstructorDto.LastName); //FormsAuthentication.SetAuthCookie(loginUserModel.Username, false); Session["access_token"] = rest.access_token; return(RedirectToAction("Index", "Home")); } ViewBag.LoginError = "Kullanıcı Adı ve paralo uyuşmamaktadır!"; } return(View(loginUserModel)); }
public ActionResult Login(LoginViewModel source) { if (All.MS().CheckNullable(x => x.MemberAccount == source.MemberAccount && x.Password != null)) { if (!All.MS().CheckEmailVerify(source.MemberAccount)) { TempData["Message"] = "請先到信箱啟動驗證. Please verify your email first."; return(Redirect(Request.UrlReferrer.ToString())); } var Account = All.MS().UserLogin(source.MemberAccount, source.Password); if (Account != null) { #region ===驗證票證=== var role = All.MRS().GetUserRole(Account.RoleID); AuthenticationHelper.CreateAuthCookie(Account.MemberID, Account.Name, Account.Email, Account.Password, role.RoleName, source.RememberMe); #endregion return(RedirectToAction <HomeController>(x => x.Index())); } TempData["Message"] = "帳號或密碼輸入錯誤!! Invallid Account or Password."; return(Redirect(Request.UrlReferrer.ToString())); } TempData["Message"] = "帳號或密碼輸入錯誤!! Invallid Account or Password."; return(Redirect(Request.UrlReferrer.ToString())); }
public void Login(UserLoginViewModel loginModel) { User user = GetByUserNameAndPassword(loginModel.UserName, loginModel.Password); if (user != null) { AuthenticationHelper.CreateAuthCookie(loginModel.UserName, "", _userDal.GetUserRoles(user).ToArray(), DateTime.Now.AddDays(1), loginModel.RememberMe); } }
public ActionResult Login(string userName, string password) { var user = _userService.GetByUsernameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return(RedirectToAction("Index", "Product")); } return(new HttpStatusCodeResult(401)); }
public string Login() { var user = _userService.GetByUserNameAndPassword("furkan", "12345"); if (user != null) { AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(p => p.RoleName).ToArray(), false, user.UserName, user.LastName); return("user is authenticated"); } return("user is not authenticated"); }
// GET: Account public string Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(t => t.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is authenticated!"); } return("User is NOT authenticated!"); }
public string Login(string userName, string password) //We can user Querystring for testing "AuthenticationHelper" as simply. { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.getUserRoles(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is authenticated!"); } return("User is not authenticated!"); }
// GET: Account public string Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(userName, password);//Veritabanında bu kullanıcı adı ve şifresi olan kullanıcıyı alıyoruz if (user != null) { //Kullanıcı giriş yapabiliyorsa kullanıcının bilgilerini cookie'de tutuyoruz. AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(1), _userService.GetUserRoles(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is Authenticated"); } return("User is Not Authenticated"); }
public string LoginTest() { AuthenticationHelper.CreateAuthCookie(new Guid(), "henimex", "*****@*****.**", DateTime.Now.AddDays(15), new[] { "Admin" }, false, "Ferhat", "Oygur"); return("User is Authorized"); }
// GET: User public string Login(string userName, string password) { var user = _service.GetbyUserAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), userName, user.Email, DateTime.Now.AddDays(15), _service.GetUserRole(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is Authenticated"); } return("User is Not Authenticated"); }
public ActionResult Login(string userName, string password) { var user = _accountService.GetByUserNameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, DateTime.Now.AddDays(15), new[] { "Admin" }, false); Session["Account"] = user.UserName; return(RedirectToAction("Index", "Employee")); } ViewBag.message = "User is not authenticated"; return(View()); }
// GET: Person public string Login(string userName, string password) { var user = _personService.GetByUserNameAndPassword("ogulcanakca", "12345"); if (user != null) { AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _personService.GetUserRoleItems(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is authenticated!"); } else { return("UserName is not authenticated"); } }
public ActionResult Login(LoginViewModel loginViewModel) { try { Users user = demoDB.Users.Where(w => w.Email == loginViewModel.Email && w.Password == loginViewModel.Password).FirstOrDefault(); if (user != null) { AuthenticationHelper.CreateAuthCookie(user.Id, user.Firstname, user.Lastname, user.Email, user.Password, user.UserRoles.Select(s => s.Roles.Rolename).ToArray(), user.Status); return(Redirect("~/")); } return(Redirect("~/Account/Login")); } catch (Exception ex) { return(Redirect("~/Account/Login")); } }
public ActionResult Login(string userName, string password, bool rememberMe = true) { var userControl = _userService.GetByUserNameAndPassword(userName, password); if (userControl != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), userControl.UserName, userControl.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(userControl).Select(u => u.RoleName).ToArray() , rememberMe, userControl.FirstName, userControl.LastName ); return(RedirectToAction("Index", "Post")); } TempData["message"] = "user not found"; return(View()); }
// GET: Account public string Login(string userName, string password)//Bunları query string ile almak gerekecek { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { //Normal şartlarda önce kullanıcı db de var mı diye kontrol etmek lazım AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is authenticated!"); } return("User is not authenticated!"); }
// GET: Account public String Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), new[] { "Student" }, false, user.FirstName, user.LastName); return("User is authenticated!"); } return("User is NOT authenticated!"); }
public string Login(string UserName, string Password) { var student = _studentService.GetByEmailAndPassword(UserName, Password); if (student != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), userName: student.MailAddress.Substring(0, student.MailAddress.IndexOf('@')), Email: student.MailAddress, expiration: DateTime.Now.AddDays(15), _studentService.GetStudentRoles(student).Select(z => z.RoleName).ToArray(), false, FullName: student.FullName ); } return("User is not authenticated !"); }
// GET: Account public ActionResult Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.UserEmail, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(x => x.RoleName).ToArray(), false, user.UserFirstName, user.UserLastName); return(View()); //return "User is Authenticated!" } return(View("User is NOT Authenticated!")); //"User is NOT Authenticated!"; }
// GET: Account public string Login(string userName = "******", string password = "******") { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { var userRoles = _userService.GetRolesByUser(user).Select(x => x.RoleName).ToArray(); AuthenticationHelper.CreateAuthCookie( user.Id, user.UserName, user.Email, DateTime.Now.AddDays(15), userRoles, false, user.FirstName, user.LastName); return("user is authenticated"); } return("user is not authenticated"); }
// GET: Account public string Login(string username, string password) { var user = _userService.GetByUserNameAndPassword(username, password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), new[] { "Admin" }, // _userService.GetUserRoles(user).Select(u=>u.RoleName).ToArray(), false, user.FirstName, user.LastName); return("User is Authorized"); } return("User is not Authorized"); }
public string Login() { var user = _userService.GetUser("guven", "1234"); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(1), _userService.GetUserRoleItems(user).Select(u => u.RoleName).ToArray(), false, user.FirstName, user.LastName ); return("Login Success"); } return("Login Fail!"); }
public ActionResult SignIn(LoginVm model) { var user = _userService.GetByUsernamePassword(model.User.Username, model.User.Password, true); if (user == null) { TempData[C.Keys.ViewData.AlertMessage] = "Giriş yapılamadı!\nKullanıcı adı ya da şifre hatalı."; return(RedirectToAction("SignIn", "Home")); } // Giriş yap AuthenticationHelper.CreateAuthCookie( username: user.Username, roles: user.Roles.Select(x => x.Name).ToArray(), rememberMe: model.RememberMe, expires: DateTime.Now.AddDays(1), id: user.Id, fullname: user.Fullname); return(RedirectToAction("Index", "Home")); }
public ActionResult Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(TempData["userName"].ToString(), TempData["password"].ToString()); var link = _userService.GetUserRoleItems(user); if (user != null && user.IsActive == true) { AuthenticationHelper.CreateAuthCookie(new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoleItems(user).Select(x => x.RoleName).ToArray(), false, user.FirstName, user.LastName); return(RedirectToAction("Index", "Anasayfa")); } //return Redirect("NotAuthorization"); return(PartialView("NotAuthorization")); }
public ActionResult Login(LoginViewModel loginUser) { var user = _userService.GetByUserNameAndPassword(loginUser.UserName, loginUser.Password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(x => x.RoleName).ToArray(), loginUser.RememberMe, user.FirstName, user.LastName ); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Login")); }
// GET: Account public string Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(userName, password); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddDays(15), _userService.GetUserRoles(user).Select(x => x.RoleName).ToArray(), false, user.FirstName, user.LastName ); return("User is Authenticated!"); } return("User is not Authenticated!"); /* * AuthenticationHelper.CreateAuthCookie( * new Guid(), "codercengiz", "*****@*****.**", DateTime.Now.AddDays(15), * new[] { "Admin" }, false, "Cengiz", "CengizL" * ); * return "User is Authenticated!";*/ }
// GET: Account public string Login(string userName, string password) { var user = _userService.GetByUserNameAndPassword(new User { UserName = userName, Password = password }); if (user != null) { AuthenticationHelper.CreateAuthCookie( new Guid(), user.UserName, user.Email, DateTime.Now.AddSeconds(10), _userService.GetUserRoles(user).Select(ur => ur.RoleName).ToArray(), false, user.FirstName, user.LastName ); return("User is authenticated."); } return("User is not authenticated."); }