예제 #1
0
 public void Clear(long userId)
 {
     UserDataChangeTime.Update(userId, DateTime.UtcNow);
     foreach (var k in CacheKeyBuilder.GetAllKeys(userId))
     {
         cache.Remove(k);
     }
 }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] LoginView login)
        {
            var result = await userService.CheckLogin(login);

            if (result.Successed)
            {
                var token = await jwtSecurityTokenService.CreateToken(result.User);

                foreach (var k in CacheKeyBuilder.GetAllKeys(result.User.Id))
                {
                    cache.Remove(k);
                }
                return(Ok(new LoginResult {
                    User = result.User, Succeeded = true, MessageCode = result.MessageCode, Token = new JwtSecurityTokenHandler().WriteToken(token), Roles = (await userRole.GetRoleCodes(result.User)).ToArray()
                }));
            }
            else
            {
                return(BadRequest(new LoginResult {
                    Succeeded = false, MessageCode = result.MessageCode
                }));
            }
        }