public TResult Login(string name, string pwd) { _Logger.LogInformation("登录中...."); if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(pwd)) { return(TResult.Fail("用户名/密码不能为空")); } else { ClaimsIdentity claimIdentity = new ClaimsIdentity(); claimIdentity.AddClaim(new Claim(ClaimTypes.Name, name)); claimIdentity.AddClaim(new Claim(ClaimTypes.Role, "AAA")); claimIdentity.AddClaim(new Claim("自定义组策略", "this is my custom policy")); claimIdentity.AddClaim(new Claim("UserID", "012345")); AuthenticationProperties properties = new AuthenticationProperties(); properties.GetJwtAuthenticationProperties("ilbli_custom_key", DateTime.UtcNow.AddMinutes(10), claims: claimIdentity.Claims); string token = properties.GetTokenValue("ILBLI_Token"); return(TResult.DataSuccess(token)); } }
public TResult WriteAndGetCacheMore(string cacheStr) { string key = "CS"; if (!_StringService.KeyExists(key)) { _StringService.StringSet(key, cacheStr, new TimeSpan(0, 1, 0)); } var msg = _StringService.StringGet(key); return(TResult.DataSuccess(msg)); }
public TResult WriteAndGetCache(string cacheStr) { bool isExist = this._BaseCache.Exist("a"); if (!isExist) { this._BaseCache.Set("a", cacheStr, new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTimeOffset.Now.AddMinutes(1))); } var msg = this._BaseCache.Get <string>("a", out isExist); if (isExist) { return(TResult.DataSuccess(msg)); } else { return(TResult.Fail()); } }
public TResult GetUID() { var uid = _Logo.GetUID(); return(TResult.DataSuccess(uid)); }