public virtual OAuthConsent FetchFromAuthorizationRequest(OAuthUser oauthUser, JObject queryParameters) { var scopes = queryParameters.GetScopesFromAuthorizationRequest(); return(oauthUser.Consents.FirstOrDefault(c => queryParameters.GetClientIdFromAuthorizationRequest() == c.ClientId && (scopes == null || (scopes.All(s => c.Scopes.Any(sc => sc.Name == s)))))); }
public async Task <OAuthUser> RegisterViaGithub(GithubRegistrationData data, GithubUserInfo githubUserInfo) { var githubUser = new OAuthUser(); if (!oAuthService.IsGithubUserRegistered(githubUserInfo.Id)) { var user = dbContext.Users.FirstOrDefault(u => u.Email == githubUserInfo.Email); if (user == null) { user = dbContext.Users.Add(new User { UserName = githubUserInfo.Login, Email = githubUserInfo.Email, IsActive = true, ActivationToken = null }).Entity; } githubUser = new OAuthUser { User = user, OAuthId = githubUserInfo.Id, Email = githubUserInfo.Email, Login = githubUserInfo.Login }; dbContext.OAuthUsers.Add(githubUser); await dbContext.SaveChangesAsync(); } return(githubUser); }
public async Task <IUser> GetUserInfo(CancellationToken cancellationToken) { var accessToken = _tokenProviderService.GetToken(); var cacheKey = $"{new JwtSecurityToken(accessToken).Subject}"; var(isCached, cachedUserInfo) = await _cache.TryGetValueAsync(cacheKey, cancellationToken); if (isCached) { return(cachedUserInfo); } var(_, isFailure, value) = await GetUserInfoFromIdentityProvider(accessToken, cancellationToken); if (isFailure) { return(new UnidentifiedUser()); } var id = value.Claims.First(claim => claim.Type == "sub").Value; var name = value.Claims.First(claim => claim.Type == "name").Value; var email = value.Claims.First(claim => claim.Type == "email").Value; var userInfo = new OAuthUser(id, name, email); await _cache.SetAsync(cacheKey, userInfo, 60, cancellationToken); return(userInfo); }
public RedirectResult SignIn(string code, string error, string returnToUrl, string provider) { if (error != null) { return(Redirect(Session["returnToUrl"].ToString())); } else if (code == null) { _oAuthProvider = getOAuthProvider(provider); if (_oAuthProvider == null) { return(Redirect(returnToUrl)); } Session.Add("returnToUrl", returnToUrl); Session.Add("provider", provider); return(Redirect(_oAuthProvider.GetCodeUrl())); } else { _oAuthProvider = getOAuthProvider(Session["provider"].ToString()); if (_oAuthProvider == null) { return(Redirect(Session["returnToUrl"].ToString())); } OAuthUser oAuthUser = _oAuthProvider.GetOAuthUser(code); Session.Add("oAuthUser", oAuthUser); return(Redirect(Session["returnToUrl"].ToString())); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string code = ""; string companyID = ""; if (Request.QueryString["code"] != null && Request.QueryString["code"] != "") { code = Request.QueryString["code"].ToString(); string str = Request.QueryString["req"].ToString(); string req = PwdHelper.DecodeDES(str, "bingoseller"); companyID = req.Split('&')[2].Split('=')[1]; string sql2 = "select * from asm_company where id=" + companyID; DataTable d1 = DbHelperSQL.Query(sql2).Tables[0]; if (d1.Rows.Count > 0) { appid = d1.Rows[0]["appId"].ToString(); appsecret = d1.Rows[0]["wx_appsecret"].ToString(); } OAuth_Token Model = Get_token(code, companyID); OAuthUser OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid); if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息 { tupian = OAuthUser_Model.headimgurl.ToString(); //头像图片 name = OAuthUser_Model.nickname; //昵称 id = OAuthUser_Model.openid; //opendid string unionID = OAuthUser_Model.unionid; string country = OAuthUser_Model.country; string province = OAuthUser_Model.province; string city = OAuthUser_Model.city; OperUtil.setCooki("vshop_openID", id); string sql = "select * from asm_member where openID='" + id + "' and companyID=" + companyID; DataTable dt = DbHelperSQL.Query(sql).Tables[0]; if (dt.Rows.Count <= 0) { //添加会员 会员不一定必须绑定机器 只有会员有订购产品的时候才必须绑定机器 string sql1 = "INSERT INTO [dbo].[asm_member]" + " ([name],[phone],[QQ],[province],[city],[country],[addres],[AvailableMoney],[sumConsume],[sumRecharge],[createDate],[mechineID],[companyID],[age],[LastTime],[memberBH],[consumeCount],[openID],[brithday],[headurl],[nickname],unionID)" + " VALUES('" + name + "','','','" + province + "','" + city + "','','',0,0,0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','','" + companyID + "','0','','',0,'" + id + "','','" + tupian + "','" + name + "','" + unionID + "')"; DbHelperSQL.ExecuteSql(sql1); wxHelper wx = new wxHelper(companyID); string data = TemplateMessage.Member_ZC(id, OperUtil.getMessageID(companyID, "OPENTM203347141"), "恭喜您注册成为会员!", name, "恭喜您注册成为会员,您将享受到会员所有权利!"); TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data); } else { string update = "update asm_member set unionID='" + unionID + "',name='" + name + "',nickname='" + name + "',headurl='" + tupian + "' where openID='" + id + "'"; Util.Debuglog("Update=" + update, "更新会员信息.txt"); } Response.Redirect("paypage.aspx?req=" + str); } } } }
protected void Page_Load(object sender, EventArgs e) { var code = Request.QueryString["code"]; if (!string.IsNullOrEmpty(code)) { var model = Get_token(code); //作缓存 处理 //model = Refresh_token(model.refresh_token); OAuthUser OAuthUser_Model = Get_UserInfo(model.access_token, model.openid); //存入数据库 StringBuilder sb = new StringBuilder(); sb.Append("用户OPENID:" + OAuthUser_Model.openid + "<br>"); sb.Append("用户昵称:" + OAuthUser_Model.nickname + "<br>"); sb.Append("性别:" + OAuthUser_Model.sex == "1" ? "男" : (OAuthUser_Model.sex == "2" ? "女" : "未知") + "<br>"); sb.Append("所在省:" + OAuthUser_Model.province + "<br>"); sb.Append("所在市:" + OAuthUser_Model.city + "<br>"); sb.Append("所在国家:" + OAuthUser_Model.country + "<br>"); sb.Append("头像地址:" + OAuthUser_Model.headimgurl); Response.Write(sb.ToString()); #region 展示二维码 //string ticket = QRCodeHandler.CreateTicket(PartenerInfo.IsTokenExpired()); //ticket = ticket.Split('_')[0]; //url = QRCodeHandler.GetImgByTicket(ticket); #endregion } }
//获得用户信息 protected OAuthUser Get_UserInfo(string REFRESH_TOKEN, string OPENID) { // Response.Write("获得用户信息REFRESH_TOKEN:" + REFRESH_TOKEN + "||OPENID:" + OPENID); string Str = GetJson("https://api.weixin.qq.com/sns/userinfo?access_token=" + REFRESH_TOKEN + "&openid=" + OPENID); OAuthUser OAuthUser_Model = JsonHelper.ParseFromJson<OAuthUser>(Str); return OAuthUser_Model; }
public PartialViewResult SetLike(CommentLikesViewModel model) { if (Session["oAuthUser"] != null) { OAuthUser oAuthUser = (OAuthUser)Session["oAuthUser"]; Like like = _likeRepository.Likes.Where(l => l.CommentId == model.CommentId && l.UserId == oAuthUser.UserId && l.UserProvider == oAuthUser.Provider).FirstOrDefault(); if (like == null) { like = new Like(); like.UserId = oAuthUser.UserId; like.UserProvider = oAuthUser.Provider; like.CommentId = model.CommentId; _likeRepository.Save(like); } else { _likeRepository.Delete(like.Id); } } model.LikesCount = _commentRepository.GetById(model.CommentId).Likes.Count; return(PartialView("~/Views/Posts/_Like.cshtml", model)); }
public static OAuthConsent GetConsent(this OAuthUser user, string clientId, IEnumerable <string> scopes, IEnumerable <AuthorizationRequestClaimParameter> claims, AuthorizationRequestClaimTypes claimType = AuthorizationRequestClaimTypes.IdToken) { return(user.Consents.FirstOrDefault(c => c.ClientId == clientId && (scopes == null || (scopes.Where(s => s != SIDOpenIdConstants.StandardScopes.OpenIdScope.Name).All(s => c.Scopes.Any(sc => sc.Name == s)))) && (claims == null || (claims.Where(cl => cl.Type == claimType && cl.IsEssential && Jwt.Constants.USER_CLAIMS.Contains(cl.Name)) .All(cl => c.Claims.Any(scl => scl == cl.Name)))))); }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> private OAuthUser Get_UserInfo(string access_token, string oppenid) { var res = GetJson("https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + oppenid + "&lang=zh_CN"); OAuthUser OAuthUser_Model = JsonHelper.ParseFromJson <OAuthUser>(res); return(OAuthUser_Model); }
/// <summary> /// 获得用户信息 /// </summary> /// <param name="accessToken"></param> /// <param name="openId"></param> /// <returns></returns> public static OAuthUser GetUserInfo(string accessToken, string openId) { string Str = WeChatHttpUtility.GetJson(string.Format(WeChatConfiguration.GetUserInfoUrl, accessToken, openId)); OAuthUser OAuthUser_Model = JsonConvert.DeserializeObject <OAuthUser>(Str); return(OAuthUser_Model); }
//根据openid,access token获得用户信息 protected OAuthUser Get_UserInfo(string REFRESH_TOKEN, string OPENID) { string Str = GetJson("https://api.weixin.qq.com/sns/userinfo?access_token=" + REFRESH_TOKEN + "&openid=" + OPENID); OAuthUser OAuthUser_Model = JsonHelper.ParseFromJson <OAuthUser>(Str); return(OAuthUser_Model); }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="REFRESH_TOKEN"></param> /// <param name="OPENID"></param> /// <returns></returns> public OAuthUser Get_UserInfo1(string access_token, string openid) { string url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid + ""; string str = GetJson(url); OAuthUser OAuthUser_Model = SerializeUtility.JavaScriptDeserialize <OAuthUser>(str); return(OAuthUser_Model); }
public TwitterHttpClient(string consumerKey, string consumerSecret, string token, string tokenSecret) { User = new OAuthUser(consumerKey, consumerSecret, token, tokenSecret); var currentUser = JObject.Parse(GetUserCredentialsAsync().Result); User.UserScreenName = currentUser.SelectToken("screen_name").ToString(); User.Id = currentUser.SelectToken("id_str").ToString(); }
public OAuthConsent FetchFromAuthorizationRequest(OAuthUser oauthUser, JObject queryParameters) { var clientId = queryParameters.GetClientIdFromAuthorizationRequest(); var scopes = queryParameters.GetScopesFromAuthorizationRequest(); var claims = queryParameters.GetClaimsFromAuthorizationRequest(); return(oauthUser.GetConsent(clientId, scopes, claims, AuthorizationRequestClaimTypes.IdToken)); }
public TwitterHttpClient(OAuthUser user) { var currentUser = JObject.Parse(GetUserCredentialsAsync().Result); user.UserScreenName = currentUser.SelectToken("screen_name").ToString(); user.Id = User.Id = currentUser.SelectToken("id_str").ToString(); User = user; }
/// <summary> /// Authenticates the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="username">The username.</param> /// <param name="returnUrl">The return URL.</param> /// <returns></returns> public override Boolean Authenticate(HttpRequest request, out string username, out string returnUrl) { _enableLogging = GetAttributeValue("EnableLogging").AsBoolean(); username = string.Empty; returnUrl = request.QueryString["State"]; string redirectUri = GetRedirectUrl(request); if (_enableLogging) { using (var rockContext = new RockContext()) { LogEvent(rockContext, "Authenticate", "returnUrl", returnUrl); LogEvent(rockContext, "Authenticate", "redirectUri", redirectUri); } } try { // Get a new OAuth Access Token for the 'code' that was returned from the OAuth user consent redirect var restClient = new RestClient( string.Format("{0}oauth/token?grant_type=authorization_code&code={1}&redirect_uri={2}&client_id={3}&client_secret={4}", _baseUrl, request.QueryString["code"], HttpUtility.UrlEncode(redirectUri), GetAttributeValue("ClientID"), GetAttributeValue("ClientSecret"))); var restRequest = new RestRequest(Method.POST); var restResponse = restClient.Execute(restRequest); if (restResponse.StatusCode == HttpStatusCode.OK) { var accesstokenresponse = JsonConvert.DeserializeObject <accesstokenresponse>(restResponse.Content); string accessToken = accesstokenresponse.access_token; // Get information about the person who logged in using OAuth restRequest = new RestRequest(Method.GET); restRequest.AddParameter("access_token", accessToken); restRequest.AddParameter("fields", "id,first_name,last_name,email,contact,address"); restRequest.AddParameter("key", GetAttributeValue("ClientID")); restRequest.RequestFormat = DataFormat.Json; restRequest.AddHeader("Accept", "application/json"); restClient = new RestClient(GetAttributeValue("UserInfoUrl")); restResponse = restClient.Execute(restRequest); if (restResponse.StatusCode == HttpStatusCode.OK) { OAuthUser oauthUser = JsonConvert.DeserializeObject <OAuthUser>(restResponse.Content); username = GetOAuthUser(GetAttributeValue("ConnectionStatus").AsGuid(), oauthUser, accessToken); } } } catch (Exception ex) { ExceptionLogService.LogException(ex, HttpContext.Current); } return(!string.IsNullOrWhiteSpace(username)); }
public async Task <bool> Update([FromBody] OAuthUser model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } return(await _service.UpdateAsync(model)); }
//根据appid,secret,code获取微信openid、access token信息 protected OAuthUser Get_UserInfo(string Code) { string access_token = Get_token(); string Str = GetJson("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + access_token + "&code=" + Code);//企业号 //微信回传的数据为Json格式,将Json格式转化成对象i OAuthUser Oauth_Token_Model = JsonHelper.ParseFromJson <OAuthUser>(Str); return(Oauth_Token_Model); }
protected OAuthUser Get_UserInfoUnion(string token, string OPENID) { Util.Debuglog("token=" + token + ";OPENID=" + OPENID, "_获取会员信息2.txt"); string Str = GetJson("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + token + "&openid=" + OPENID + "&lang=zh_CN"); Util.Debuglog("Str=" + Str, "_获取会员信息2.txt"); OAuthUser OAuthUser_Model = JsonHelper.ParseFromJson <OAuthUser>(Str); return(OAuthUser_Model); }
//获得用户的openid public string getOpenId(string code) { var appid = Global.TheServiceAccount.AppId; var secret = Global.TheServiceAccount.AppSecret; string str = Util.GetJson("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code");//获取用户基本信息的openid OAuthUser oAuthUser = JsonHelper.ParseFromJson <OAuthUser>(str); return(oAuthUser.openid); }
private static T?ToObject <T>(this System.Text.Json.JsonElement element) where T : OAuthUser { var user = new OAuthUser(); var target = element.EnumerateObject(); user.Id = target.TryGetValue("Id"); user.Login = target.TryGetValue("Login"); user.Name = target.TryGetValue("Name"); user.Avatar_Url = target.TryGetValue("Avatar_Url"); return(user as T); }
//protected string authtest() //{ // string rt = ""; // string sql = "SELECT (case Isopen when 'False' then 0 else 1 end)as isopen FROM wx_modulem"; // DataSet ds0 = SqlUtils.MSSQLHelper.Query(sql); // for (int i=0;i<ds0.Tables[0].Rows.Count;i++) // { // rt += ds0.Tables[0].Rows[i][0].ToString(); // } // return rt; //} protected OAuthUser Get_UserInfo(string Code) { string access_token = Get_token(); token1 = Get_token(); Session["token"] = access_token; string Str = GetJson("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + access_token + "&code=" + Code);//企业号 OAuthUser Oauth_Token_Model = JsonHelper.ParseFromJson <OAuthUser>(Str); return(Oauth_Token_Model); }
protected void Page_Load(object sender, EventArgs e) { string cusid = ""; string cusname = ""; string log_id = ""; if (!IsPostBack) { //获取从wxProcess.aspx传递过来的跳转地址dir if (Request.QueryString["dir"] != null && Request.QueryString["dir"] != "") { dir = Request.QueryString["dir"].ToString(); cusid = dir.Split('|')[0]; cusname = dir.Split('|')[1]; log_id = dir.Split('|')[2]; } string code = ""; if (Request.QueryString["code"] != null && Request.QueryString["code"] != "") { //获取微信回传的code code = Request.QueryString["code"].ToString(); OAuthUser Model = Get_UserInfo(code); //获取token,存入全局变量 //判断token是否有效 Session["userid"] = Model._UserId.ToString(); // rtmsg msg = Get_Rtmsg(Model.access_token, Model.openid);这个token时长较长,但是关注的用户访问是直接pass的,所以此处无需验证 if (Model._UserId != null && Model._UserId != "") //已获取得openid及其他信息 { // //在页面上输出用户信息 Response.Write("userid:" + Model._UserId + dir); if (Request.QueryString["dir"] != null && Request.QueryString["dir"] != "") { Response.Redirect("./Wb/CheckAccount.aspx?cusid=" + cusid + "&cusname=" + cusname + "&log_id=" + log_id); } else { Response.Redirect("./Wb/Default.aspx"); } //或跳转到自己的页面,想怎么处理就怎么处理 // Response.Redirect("./web/Readme.aspx"); } else //未获得openid,回到wxProcess.aspx,访问弹出微信授权页面 { //Response.Redirect("wxProcess.aspx?auth=1"); Response.Write(code); // Response.Redirect("./web/Readme.aspx?code="+code); } } } }
public async Task <IActionResult> Index() { OAuthUser user = null; if (User.Identity.IsAuthenticated) { user = new OAuthUser(); user.Name = User.FindFirst(c => c.Type == ClaimTypes.Name)?.Value; user.AccessToken = await HttpContext.GetTokenAsync("access_token"); } return(View(user)); }
protected virtual void UpdateUser(JObject jObj, OAuthUser user) { if (jObj.ContainsKey(SimpleIdServer.Jwt.Constants.OAuthClaims.Claims)) { var claims = jObj[SimpleIdServer.Jwt.Constants.OAuthClaims.Claims] as JObject; foreach (var kvp in claims) { user.UpdateClaim(kvp.Key, kvp.Value.ToString()); } return; } }
static void Main(string[] args) { OAuthUser user = new OAuthUser(_consumerKey, _consumerSecret, _tokenKey, _tokenSecret); Task.Run(async() => { TwitterMessageService service = new TwitterMessageService(_consumerKey, _consumerSecret, _tokenKey, _tokenSecret); await service.RunService(); }); Console.ReadLine(); }
/// <summary> /// Gets OAuth user by the specified user Id or Phone number asynchronous. /// </summary> /// <param name="model">The model contains the user Id or Phone number.</param> /// <returns>A <see cref="Task{TResult}"/> represents the get operation. Task result contains the found user.</returns> public async Task <OAuthUser> GetAsync(FindUserModel model) { TUser user; if (model.Id != null) { user = await _userManager.FindByIdAsync(model.Id.ToString()); } else { user = await _userManager.FindByNameAsync(model.PhoneNumber); } if (user == null) { throw new Exception("cannot find the user by id or phone number"); } var userPrincipal = await _signInManager.CreateUserPrincipalAsync(user); if (_userManager.SupportsUserEmail) { var email = await _userManager.GetEmailAsync(user); if (!string.IsNullOrWhiteSpace(email)) { userPrincipal.Identities.First().AddClaims(new[] { new Claim(JwtClaimTypes.Email, email), new Claim(JwtClaimTypes.EmailVerified, await _userManager.IsEmailConfirmedAsync(user) ? "true" : "false", ClaimValueTypes.Boolean) }); } } if (_userManager.SupportsUserPhoneNumber) { var phoneNumber = await _userManager.GetPhoneNumberAsync(user); if (!string.IsNullOrWhiteSpace(phoneNumber)) { userPrincipal.Identities.First().AddClaims(new[] { new Claim(JwtClaimTypes.PhoneNumber, phoneNumber), new Claim(JwtClaimTypes.PhoneNumberVerified, await _userManager.IsPhoneNumberConfirmedAsync(user) ? "true" : "false", ClaimValueTypes.Boolean) }); } } return(OAuthUser.FromUser(userPrincipal)); }
public void ProcessRequest(HttpContext context) { if (!string.IsNullOrEmpty(context.Request.QueryString["code"])) { string Code = context.Request.QueryString["code"].ToString(); WeChatoAuth oauth = new WeChatoAuth(); OAuth_Token Model = oauth.Get_Token(WeChatConfig.AppId, WeChatConfig.AppSecret, Code); OAuthUser OAuthUser_Model = oauth.Get_UserInfo(Model.access_token, Model.openid); //写入日志 LogHelper.Logtest(JsonConvert.SerializeObject(OAuthUser_Model)); context.Response.Write(JsonConvert.SerializeObject(OAuthUser_Model)); } }
protected void insertNormalAccount(OAuthUser user, string IDNo, string Mobile) { //ModelInvokeResult<NormalAccountPK> result = new ModelInvokeResult<NormalAccountPK> { Success = true }; NormalAccount normalAccount = new NormalAccount(); try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); normalAccount.AccountCode = user.openid + "$" + user.nickname; normalAccount.IDNo = IDNo; normalAccount.Mobile = Mobile; normalAccount.CheckInTime = DateTime.Now; normalAccount.NickName = user.nickname; normalAccount.Gender = user.sex; normalAccount.Language = user.language; normalAccount.Country = user.country; normalAccount.Province = user.province; normalAccount.City = user.city; normalAccount.HeadImgUrl = user.headimgurl; //更新条件 var parameterObject = normalAccount.ToStringObjectDictionary(false); parameterObject["OpenId"] = user.openid; var dictionary = new StringObjectDictionary().MixInJson("{'OpenId':'" + user.openid + "'}"); int count = BuilderFactory.DefaultBulder().List <NormalAccount>(dictionary).Count; Util.WriteTxt("count:" + count); if (count == 0) { normalAccount.OpenId = user.openid; Util.WriteTxt("插入1111"); statements.Add(new IBatisNetBatchStatement { StatementName = normalAccount.GetCreateMethodName(), ParameterObject = normalAccount.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT }); } else { Util.WriteTxt("更新1111"); //Util.WriteTxt("更新" + normalAccount.NickName + " : " + normalAccount.Language + " openid: " + user.openid); statements.Add(new IBatisNetBatchStatement { StatementName = "NormalAccount_Update2", ParameterObject = parameterObject, Type = SqlExecuteType.UPDATE }); } BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); } catch (Exception ex) { Util.WriteTxt(ex.ToString()); } //Util.WriteTxt("更新完毕"); }
public void Validate() { OAuthUser user = new OAuthUser { Id = Identifier, ApplicationName = configuration.ApplicationName, Username = Username, Email = Email }; user.AddExternalAuthenticator(new ExternalAuthenticator { ExternalIdentifier = ExternalIdentifier, Email = Email, Username = Username, ExternalAuthenticationType = ExternalProvider, Token = Token, TokenSecret = TokenSecret }); Results = validatorResolver.CreateValidator().Validate(user); }
public LinkViewModel(OAuthUser user) { Username = user.Username; }