/// <inheritdoc /> /// <summary> /// Uid查询用户 /// </summary> /// <param name="uid"></param> /// <returns></returns> public (Status status, AppUser user) FindUser(string uid) { if (IsNullOrWhiteSpace(uid)) { return(Status.InputIllegal, null); } var u = _db.Find(uid); return(u == null ? (Status.UidNotFind, null) : (Status.Ok, u)); }
/// <inheritdoc /> /// <summary> /// 登陆 /// </summary> /// <param name="uid"></param> /// <param name="pwd"></param> /// <returns></returns> public (Status status, string jwt) Login(string uid, string pwd) { // 空值检查 if (AnyNullOrWhiteSpace(uid, pwd)) { return(Status.InputIllegal, null); } // 判断Uid是否存在 var user = _db.Find(uid); if (user == null) { return(Status.UidNotFind, null); } // 检查密码是否正确 if (!MakePwdHash(pwd).SequenceEqual(user.PwHash)) { return(Status.PwdWrong, null); } _appUser = user; return(Status.Ok, MakeJwt(uid, user.Role)); }