Exemplo n.º 1
0
        public async Task <Result <JobUserEntity> > LoginAsync(Input input)
        {
            var result = new Result <JobUserEntity> {
                Message = "查询用户成功!"
            };

            try
            {
                input.Extens.TryGetValue("UserName", out string name);
                input.Extens.TryGetValue("Password", out string pwd);
                pwd         = Secret.DesDecrypt(pwd);
                result.Data = await _taskDao.QueryUserAsync(name.Trim(), Secret.GetMd5(pwd.Trim()));

                result.Message = $"{result.Data.RealName ?? name} 欢迎你!";
                if (result.Data == null || result.Data.Id <= 0)
                {
                    throw new Exception("查无此人!");
                }
                await _taskDao.LastLoginTimeAsync(result.Data.Id);
            }
            catch (Exception ex)
            {
                result.Success     = false;
                result.Message     = $"查无此人!";
                result.ErrorDetail = ex.Message;
                _logger.LogError(ex, $"input:{input.ToJson()} 查询用户失败!");
            }
            return(result);
        }
Exemplo n.º 2
0
        protected async Task UserCheckAsync()
        {
            Console.WriteLine("UserCheck:" + SessionStorage.GetId());
            var user = await SessionStorage.GetItemAsync <JobUserEntity>(SessionStorage.GetId());

            if (user == null || user.Id <= 0)
            {
                user = await LocalStorage.GetItemAsync <JobUserEntity>($"__User");

                if (user != null && user.Id > 0)
                {
                    var re = await UserLoginAsync(user.UserName, Secret.DesDecrypt(user.Password));

                    if (re.Success)
                    {
                        await SessionStorage.SetItemAsync(SessionStorage.GetId(), re.Data);
                    }
                    else
                    {
                        Nav.NavigateTo("/login");
                    }
                }
                else
                {
                    await SessionStorage.ClearAsync();

                    Nav.NavigateTo("/login");
                }
            }
        }
Exemplo n.º 3
0
        protected override async Task OnInitializedAsync()
        {
            var user = await LocalStorage.GetItemAsync <JobUserEntity>($"__User");

            Console.WriteLine("__User:" + user.ToJson());
            if (user != null && user.Id > 0)
            {
                UserName = user.UserName;
                Password = Secret.DesDecrypt(user.Password);
                Remember = true;
                await UserLoginAsync();
            }
            ;
        }