Example #1
0
 protected override void OnEnable()
 {
     this.loginMode   = LoginViewMode.State1;
     GTGlobal.IsAlong = PlayerPrefs.GetInt("Along") == 0;
     this.InitView();
     this.InitGameModeView();
     this.ShowCurrServer();
     this.ShowUsernameAndPassword();
 }
Example #2
0
 protected override void OnEnable()
 {
     this.loginMode = LoginViewMode.State1;
     GTGlobal.Along = true;
     this.InitModel();
     this.InitView();
     this.InitGameModeView();
     this.ShowCurrServer();
     this.ShowUsernameAndPassword();
 }
Example #3
0
 private void OnNextClick(GameObject go)
 {
     if (GTGlobal.Along)
     {
         NetworkManager.Instance.AddMessageCenterHandler();
         this.loginMode    = LoginViewMode.State3;
         GTXmlHelper.Write = true;
     }
     else
     {
         this.loginMode    = LoginViewMode.State2;
         GTXmlHelper.Write = false;
         NetworkManager.Instance.ConnectLoginServer();
     }
     this.InitGameModeView();
 }
Example #4
0
        //Fonction de VĂ©rification de l'existance d'un utilisateur
        public User IsValidUser(LoginViewMode model)
        {
            using (var db = new DbCaimanContext())
            {
                User user = db.Users.Where(q => q.UserMail.Equals(model.UserMail) && q.Password.Equals(model.Password)).SingleOrDefault();

                if (user == null)
                {
                    return(null);
                }
                else
                {
                    return(user);
                }
            }
        }
Example #5
0
    private void OnNextClick(GameObject go)
    {
        GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK);
        if (GTGlobal.IsAlong)
        {
            NetworkManager.Instance.AddMessageCenterHandler();
            this.loginMode       = LoginViewMode.State3;
            GTXmlHelper.CanWrite = true;
        }
        else
        {
            this.loginMode       = LoginViewMode.State2;
            GTXmlHelper.CanWrite = false;
            NetworkManager.Instance.ConnectLoginServer();
        }

        PlayerPrefs.SetInt("Along", GTGlobal.IsAlong ? 0 : 1);
        this.InitGameModeView();
    }
Example #6
0
        public async Task <IActionResult> Login(LoginViewMode viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = await this._userManager.FindByNameAsync(viewModel.UserName);

                if (user != null && await this._userManager.CheckPasswordAsync(user, viewModel.Password))
                {
                    var identity = new ClaimsIdentity("cookies");
                    identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
                    identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName));

                    await HttpContext.SignInAsync("cookies", new ClaimsPrincipal(identity));

                    return(RedirectToAction("Index", "Home"));
                }

                ModelState.AddModelError("", "Invalid UserName or Password");
            }

            return(View());
        }
Example #7
0
        public ActionResult Login(LoginViewMode model)
        {
            if (ModelState.IsValid)
            {
                var isValidUser = IsValidUser(model);

                if (isValidUser != null)
                {
                    FormsAuthentication.SetAuthCookie(model.UserMail, true); //Ticket d'authentification, valeur false pur empĂȘcher l'enregistrement des cookies sur le navigateur
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("Echec de connexion", "Tentative de connexion non valide");
                    return(View());
                }
            }
            else
            {
                return(View(model));
            }
        }
        public async Task <IActionResult> Login([FromBody] LoginViewMode loginView)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(BadRequest("You are already logged in!"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = await _userManager.FindByNameAsync(loginView.UserName);

            if (user != null)
            {
                var res = await _userManager.CheckPasswordAsync(user, loginView.Password);

                if (res)
                {
                    var jwt = await GenerateJwt(user);

                    return(Ok(jwt));
                }

                ModelState.AddModelError("", "Invalid password");
                if (user.FacebookId != null)
                {
                    ModelState.AddModelError("", "Your first sign in request was probably made by log in with FB button, so please try to login the same way");
                }
            }
            else
            {
                ModelState.AddModelError("Errors", "User not found");
            }
            return(BadRequest(ModelState));
        }
Example #9
0
 private void OnRecvAccLogin()
 {
     this.loginMode = LoginViewMode.State3;
     this.InitGameModeView();
     this.ShowCurrServer();
 }
Example #10
0
        public async Task <IActionResult> Login(LoginViewMode viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = await this._userManager.FindByNameAsync(viewModel.UserName);

                if (user != null && !await this._userManager.IsLockedOutAsync(user))
                {
                    if (await this._userManager.CheckPasswordAsync(user, viewModel.Password))
                    {
                        if (!await this._userManager.IsEmailConfirmedAsync(user))
                        {
                            ModelState.AddModelError("", "Email is not confirmed");
                            return(View());
                        }

                        await this._userManager.ResetAccessFailedCountAsync(user);

                        // if having a 2SV requirement
                        if (await this._userManager.GetTwoFactorEnabledAsync(user))
                        {
                            var validProviders = await this._userManager.GetValidTwoFactorProvidersAsync(user);

                            if (validProviders.Contains(this._userManager.Options.Tokens.AuthenticatorTokenProvider))
                            {
                                await HttpContext.SignInAsync(IdentityConstants.TwoFactorUserIdScheme, Store2FA(user.Id, this._userManager.Options.Tokens.AuthenticatorTokenProvider));

                                return(RedirectToAction("TwoFactor", "Account"));
                            }

                            if (validProviders.Contains("Email"))
                            {
                                var token = await this._userManager.GenerateTwoFactorTokenAsync(user, "Email");

                                System.IO.File.WriteAllText("email2SA.txt", token);

                                await HttpContext.SignInAsync(IdentityConstants.TwoFactorUserIdScheme, Store2FA(user.Id, "Email"));

                                return(RedirectToAction("TwoFactor", "Account"));
                            }
                        }

                        var principal = await this._providerFactory.CreateAsync(user);

                        await HttpContext.SignInAsync(IdentityConstants.ApplicationScheme, principal);

                        return(RedirectToAction("Index", "Home"));

                        // var signInResult = await this._signInManager.PasswordSignInAsync(viewModel.UserName, viewModel.Password, false, false);

                        // if (signInResult.Succeeded)
                        // {
                        //     return RedirectToAction("Index", "Home");
                        // }
                    }

                    await this._userManager.AccessFailedAsync(user);

                    if (await this._userManager.IsLockedOutAsync(user))
                    {
                        // email user, notifying them of lockout
                    }
                }

                ModelState.AddModelError("", "Invalid UserName or Password");
            }

            return(View());
        }