Exemple #1
0
 private void RefreshUI()
 {
     Debug.Log("refresh ui");
     m_lblRegist.text = Localization.Get(10006);
     if (CheckLocal())
     {
         NetCommand.Instance.LoginUser(mUserid, (res) =>
         {
             NUser nuser = GameCore.Util.Instance.Get <NUser>(res);
             GameBaseInfo.Instance.user = nuser;
             m_user.label.text          = m_receive.label.text = nuser.name;
             // m_type.text = nuser.type == 1 ? Localization.Get(10008) : Localization.Get(10009);
             m_address.label.text = nuser.addr;
             m_tel.label.text     = nuser.tel.ToString();
             m_balance.text       = Localization.Get(10031) + string.Format("{0:f}", GameBaseInfo.Instance.user.balance);
             m_paycnt.text        = Localization.Get(10031) + string.Format("{0:f}", GameBaseInfo.Instance.GetPaycnt());
             TextureHandler.Instance.LoadHeadTexture(PlayerPrefs.GetString(PlayerprefID.HEADICO, "010"),
                                                     (txt) =>
             {
                 m_head.mainTexture = txt as Texture2D;
             });
         });
     }
     else
     {
         UIHandler.Instance.Push(PageID.Regist);
     }
 }
Exemple #2
0
    public override void RefreshView()
    {
        base.RefreshView();

        UIEventListener.Get(m_objOK).onClick = OnClickBtn;

        UIEventListener.Get(m_poplist.gameObject).onClick = OnPopClick;

        if (GameBaseInfo.Instance.user != null)
        {
            RefreshUI();
        }
        else if (!PlayerPrefs.HasKey(PlayerprefID.USERID))
        {
            Close();
            Toast.Instance.Show(10075);
            UIHandler.Instance.Push(PageID.Regist);
        }
        else
        {
            NetCommand.Instance.LoginUser(PlayerPrefs.GetString(PlayerprefID.USERID), (string res) =>
            {
                NUser nuser = Util.Instance.Get <NUser>(res);
                GameBaseInfo.Instance.user = nuser;
                RefreshUI();
            });
        }
    }
Exemple #3
0
        public IDataResult <AccessToken> CreateAccessToken(NUser user)
        {
            var claims      = _userService.GetClaims(user);
            var accessToken = _tokenHelper.CreateToken(user, claims);

            return(new SuccessDataResult <AccessToken>(accessToken, "Messages.AccessTokenCreated"));
        }
Exemple #4
0
    private void OnLogin(GameObject go)
    {
        if (!Util.Instance.CheckPhoneValid(m_tel.label.text.Trim()))
        {
            Toast.Instance.Show(10017);
            return;
        }
        if (timerCnt <= 0)
        {
            Toast.Instance.Show(10014);
            return;
        }
        int code = 1000;

        if (!int.TryParse(m_code.label.text.Trim(), out code))
        {
            Debug.LogError("msg: " + m_code.label.text + " code: " + code);
        }
#if !SMS
        if (randCode != code)
        {
            Toast.Instance.Show(10016);
            return;
        }
#endif
        NetCommand.Instance.LoginUser(m_tel.label.text, (res) =>
        {
            PlayerPrefs.SetString(PlayerprefID.USERID, m_tel.label.text);
            NUser nuser = Util.Instance.Get <NUser>(res);
            GameBaseInfo.Instance.user = nuser;
            Debug.Log("regist use success!");
            Close();
        });
    }
        public IActionResult Delete(NUser user)
        {
            var result = _iUserService.Delete(user);

            if (result.Success == true)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Exemple #6
0
        private static void UserAddTest()
        {
            UserManager userManager = new UserManager(new EfUserDAL());
            NUser       user        = new NUser();

            user.FirstName = "Yeni user";
            user.LastName  = "Yeni soyad";
            user.Email     = "*****@*****.**";

            userManager.Add(user);
        }
Exemple #7
0
        private IEnumerable <Claim> SetClaims(NUser user, List <NOperationClaim> operationClaims)
        {
            var claims = new List <Claim>();

            claims.AddNameIdentifier(user.Id.ToString());
            claims.AddEmail(user.Email);
            claims.AddName($"{user.FirstName} {user.LastName}");
            claims.AddRoles(operationClaims.Select(c => c.Name).ToArray());

            return(claims);
        }
Exemple #8
0
        public JwtSecurityToken CreateJwtSecurityToken(NTokenOptions tokenOptions, NUser user,
                                                       SigningCredentials signingCredentials, List <NOperationClaim> operationClaims)
        {
            var jwt = new JwtSecurityToken(
                issuer: tokenOptions.Issuer,
                audience: tokenOptions.Audience,
                expires: _accessTokenExpiration,
                notBefore: DateTime.Now,
                claims: SetClaims(user, operationClaims),
                signingCredentials: signingCredentials
                );

            return(jwt);
        }
Exemple #9
0
        public AccessToken CreateToken(NUser user, List <NOperationClaim> operationClaims)
        {
            _accessTokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.AccessTokenExpiration);
            var securityKey        = SecurityKeyHelper.CreateSecurityKey(_tokenOptions.SecurityKey);
            var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey);
            var jwt = CreateJwtSecurityToken(_tokenOptions, user, signingCredentials, operationClaims);
            var jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
            var token = jwtSecurityTokenHandler.WriteToken(jwt);

            return(new AccessToken
            {
                Token = token,
                Expiration = _accessTokenExpiration
            });
        }
Exemple #10
0
        public IDataResult <NUser> Register(UserForRegisterDto userForRegisterDto, string password)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
            var user = new NUser
            {
                Email        = userForRegisterDto.Email,
                FirstName    = userForRegisterDto.FirstName,
                LastName     = userForRegisterDto.LastName,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                Status       = true
            };

            _userService.Add(user);
            return(new SuccessDataResult <NUser>(user, "Messages.UserRegistered"));
        }
Exemple #11
0
        private void Ingresar()
        {
            if (txtUsername.Text != "USUARIO")
            {
                if (txtPassword.Text != "CONTRASEÑA")
                {
                    NUser user         = new NUser();
                    bool  validarLogin = user.LoginUser(txtUsername.Text, txtPassword.Text);

                    if (validarLogin)
                    {
                        if (UserCache.Estado == "A")
                        {
                            FormPrincipal principal = new FormPrincipal();
                            this.Hide();

                            LoginBienvenida bienvenida = new LoginBienvenida();
                            bienvenida.ShowDialog();

                            principal.Show();
                            principal.FormClosed += CerrarSesion;
                        }
                        else
                        {
                            MensajeError("Usuario deshabilitado.\n      Póngase en contacto con el administrador");
                        }
                    }
                    else
                    {
                        MensajeError("Usuario o contraseña incorrecta.\n      Por favor intente otra vez");
                        txtPassword.Clear();
                        txtUsername.SelectAll();
                        txtUsername.Focus();
                    }
                }
                else
                {
                    MensajeError("Por favor ingrese su contraseña");
                }
            }
            else
            {
                MensajeError("Por favor ingrese su usuario");
            }
        }
Exemple #12
0
 public List <NOperationClaim> GetClaims(NUser user)
 {
     return(_iUserDal.GetClaims(user));
 }
Exemple #13
0
 public IResult Delete(NUser user)
 {
     _iUserDal.Delete(user);
     return(new SuccessResult(Messages.UserDeleted));
 }
Exemple #14
0
 public IResult Update(NUser user)
 {
     _iUserDal.Update(user);
     return(new SuccessResult(Messages.UserUpdated));
 }
Exemple #15
0
 public IResult Add(NUser user)
 {
     _iUserDal.Add(user);
     return(new SuccessResult(Messages.UserAdded));
 }