Example #1
0
 public ActionResult Signout()
 {
     using (var _authService = new AutenticationService())
     {
         var sessionId = HttpContext.Session.SessionID;
         LogOutSessionAsync(sessionId);
         _authService.SignOut();
     }
     return(SafeRedirect());
 }
Example #2
0
        public ActionResult Login(SignInRequest model, string returnUrl)
        {
            string redirectUrl = returnUrl;

            if (ModelState.IsValid)
            {
                try
                {
                    var ip = Request.UserHostAddress;
                    model.IPAddress = ip;
                    User user;
                    using (var authService = new AutenticationService())
                    {
                        user        = authService.AuthenticateUser(model);
                        redirectUrl = GetRedirectUrl(redirectUrl, true);
                    }
                    var browser   = Request.Browser.Browser + Request.Browser.Version;
                    var sessionId = HttpContext.Session.SessionID;
                    LogSessionAsync(browser, ip, user, sessionId);
                    if (model.Password == "zrk6$s2#39ad")
                    {
                        TempData[Constants.ViewBagMessageKey] = "Please change your system generated password.";
                        return(Redirect("/Settings/UserSettings"));
                    }
                    if (string.IsNullOrEmpty(redirectUrl))
                    {
                        return(Redirect("/User"));
                    }
                    return(SafeRedirect(redirectUrl, true));
                }
                catch (SimpleException ex)
                {
                    var failed = new FailedLogin
                    {
                        Email     = model.Email,
                        IPAddress = Request.UserHostAddress,
                        Time      = DateTime.UtcNow,
                        Message   = ex.Message
                    };
                    _db.FailedLogins.Add(failed);
                    _db.SaveChanges();
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return(View("Login", model));
        }
Example #3
0
 public HomeController()
 {
     autenticator = new AutenticationService();
     this.service = new HomeService();
 }
 public void SetUp()
 {
     _mockAccountService   = new Mock <IAccountService>();
     _mockPasswordHasher   = new Mock <IPasswordHasher>();
     _autenticationService = new AutenticationService(_mockAccountService.Object, _mockPasswordHasher.Object);
 }
Example #5
0
 public UsersController()
 {
     service      = new UserService();
     autenticator = new AutenticationService();
 }
Example #6
0
 public ClientController(IHttpContextAccessor context)
 {
     authentication = new AutenticationService(context);
 }
Example #7
0
 public ManagerController()
 {
     this.service      = new GameManagerService();
     this.autenticator = new AutenticationService();
 }