Exemple #1
0
 public IHttpActionResult Get([FromBody] GetTokenRequest request)
 {
     if (CheckUser(request.Username, request.Password))
     {
         var token = JwtUtil.GenerateToken(request.Username);
         return(Json(new { token }));
     }
     return(Unauthorized());
 }
Exemple #2
0
        public ActionResult <string> Get(string deviceId)
        {
            var token    = JwtUtil.GenerateToken(deviceId);
            var response = new GetTokenResponse()
            {
                Result = (int)ResultCode.Success, Token = token, GameServerAddress = _config.GameServerAddress
            };

            return(JsonConvert.SerializeObject(response));
        }
Exemple #3
0
        public IHttpActionResult Signin([FromBody] SigninRequest request)
        {
            try
            {
                var decrypted = RsaEncryption.Decrypt(request.Request);
                var auth      = JsonConvert.DeserializeObject <AuthModel>(decrypted);

                // use hard-coded user name and hashed password
                if (auth.Username.ToLower() == "demo" && auth.Password == "QBG6AuURBMZ4wxp2pERIWzjzhl5QTYnDoKgLQ5uxojc=")
                {
                    return(Ok(JwtUtil.GenerateToken(auth)));
                }

                return(Unauthorized());
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }