Ejemplo n.º 1
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);
            }
        }