Exemplo n.º 1
0
 public async Task LogoutAsync()
 {
     await Task.Run(() => {
         LoginInfoCache.SetAuthenticateModelAndAuthenticateResultModel(null, null);
         LoginInfoCache.SetPermissions(null);
     });
 }
Exemplo n.º 2
0
        public async Task <AuthenticateResultModel> LoginAsync(AuthenticateModel authenticateModel, bool isServerless)
        {
            if (!isServerless)
            {
                AuthenticateResultModel authenticateResultModel = await authorizationManager.AuthorizationAsync(authenticateModel, true);

                if (!authenticateResultModel.AccessToken.IsNullOrEmpty())
                {
                    LoginInfoCache.SetAuthenticateModelAndAuthenticateResultModel(authenticateModel, authenticateResultModel);
                    IEnumerable <FlatPermissionWithLevelDto> premissions = await authorizationManager.GetAllPermissionsAsync();

                    LoginInfoCache.SetPermissions(premissions);
                    Logger.Info("login success!");
                    return(authenticateResultModel);
                }
                Logger.Warn("login fail!" + JsonConvert.SerializeObject(authenticateResultModel));
                return(authenticateResultModel);
            }
            else
            { //脱机登录
                runtimeSetting.RuntimeStatus = RuntimeStatus.Serverless;
                var authenticateResultModel = new AuthenticateResultModel {
                    AccessToken = "Serverless"
                };
                LoginInfoCache.SetAuthenticateModelAndAuthenticateResultModel(authenticateModel, authenticateResultModel);
                return(authenticateResultModel);
            }
        }
Exemplo n.º 3
0
 public AuthenticateResultModel Login(AuthenticateModel authenticateModel, bool isServerless)
 {
     if (!isServerless)
     {
         AuthenticateResultModel authenticateResultModel = authorizationManager.Authorization(authenticateModel, true);
         if (authenticateResultModel != null && !authenticateResultModel.AccessToken.IsNullOrEmpty())
         {
             LoginInfoCache.SetAuthenticateModelAndAuthenticateResultModel(authenticateModel, authenticateResultModel);
             IEnumerable <FlatPermissionWithLevelDto> premissions = authorizationManager.GetAllPermissions();
             LoginInfoCache.SetPermissions(premissions);
             runtimeSetting.RuntimeStatus = RuntimeStatus.Common;
             Logger.Info("login success!");
             return(authenticateResultModel);
         }
         Logger.Warn("login fail!" + JsonConvert.SerializeObject(authenticateResultModel));
         return(authenticateResultModel);
     }
     else   //脱机登录
     {
         runtimeSetting.RuntimeStatus = RuntimeStatus.Serverless;
         var authenticateResultModel = new AuthenticateResultModel {
             AccessToken = "Serverless", UserId = ServerlessConfig.ServerlessUserId
         };
         LoginInfoCache.SetAuthenticateModelAndAuthenticateResultModel(authenticateModel, authenticateResultModel);
         return(authenticateResultModel);
     }
 }
Exemplo n.º 4
0
 public void Logout()
 {
     LoginInfoCache.SetAuthenticateModelAndAuthenticateResultModel(null, null);
     LoginInfoCache.SetPermissions(null);
 }