/// <summary> /// 登录记录 /// </summary> /// <param name="userInfo"></param> /// <param name="ip"></param> /// <param name="type"></param> public void LoginRecord(UserInfoDto userInfo, string ip, LoginType type) { var result = ip.GetPhysicsAddressInfo().Result; if (result?.Status != 0) { return; } string addr = result.AddressResult.FormattedAddress; string prov = result.AddressResult.AddressComponent.Province; var record = new LoginRecord() { IP = ip, LoginTime = DateTime.Now, LoginType = type, PhysicAddress = addr, Province = prov }; var u = _userInfoService.GetByUsername(userInfo.Username); u.LoginRecord.Add(record); _userInfoService.SaveChanges(); var content = new Template(File.ReadAllText(Path.Combine(_hostEnvironment.WebRootPath, "template", "login.html"))) .Set("name", u.Username) .Set("time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) .Set("ip", record.IP) .Set("address", record.PhysicAddress).Render(); CommonHelper.SendMail(_settingService.Get(s => s.Name.Equals("Title")).Value + "账号登录通知", content, _settingService.Get(s => s.Name.Equals("ReceiveEmail")).Value, "127.0.0.1"); }
public UserProfiloViewModel() { Info = new UserInfoDto(); Eventi = new ObservableCollection <EventoDtoOutput>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); }
private Roles GetRole(UserInfoDto user) { if (user.Role.Equals(AdminRole) && !user.CompanyId.HasValue) { return(Roles.SuperAdmin); } if (user.Role.Equals(AdminRole) && user.CompanyDetail.CompanyType.Equals(CompanyTypeBuyer)) { return(Roles.BuyerAdmin); } if (user.Role.Equals(AdminRole) && user.CompanyDetail.CompanyType.Equals(CompanyTypeSupplier)) { return(Roles.SupplierAdmin); } if (user.Role.Equals(UserRole) && user.CompanyDetail.CompanyType.Equals(CompanyTypeBuyer)) { return(Roles.BuyerUser); } if (user.Role.Equals(UserRole) && user.CompanyDetail.CompanyType.Equals(CompanyTypeSupplier)) { return(Roles.SupplierUser); } else { return(Roles.BuyerUser); } }
/// <summary> /// Loads a <see cref="UserInfo"/> object from the given <see cref="UserInfoDto"/>. /// </summary> /// <param name="data">The UserInfoDto to use.</param> private void Fetch(UserInfoDto data) { // Value properties Id = data.Id; User_name = data.User_name; Password = data.Password; Password_salt = data.Password_salt; Password_question = data.Password_question; Password_answer = data.Password_answer; Is_approved = data.Is_approved; Fullname = data.Fullname; Email = data.Email; Tel = data.Tel; LoadProperty(Last_login_dateProperty, data.Last_login_date); LoadProperty(Last_password_changed_dateProperty, data.Last_password_changed_date); LoadProperty(Last_lockout_dateProperty, data.Last_lockout_date); Failed_password_attempt_count = data.Failed_password_attempt_count; LoadProperty(Failed_password_attempt_window_startProperty, data.Failed_password_attempt_window_start); Failed_password_answer_attempt_count = data.Failed_password_answer_attempt_count; LoadProperty(Failed_password_answer_attempt_window_startProperty, data.Failed_password_answer_attempt_window_start); LoadProperty(BirthdayProperty, data.Birthday); Address = data.Address; Website = data.Website; Avatar = data.Avatar; Is_lock = data.Is_lock; User_type = data.User_type; LoadProperty(Last_modifiedProperty, data.Last_modified); Last_user_id = data.Last_user_id; var args = new DataPortalHookArgs(data); OnFetchRead(args); }
public ActionResult Login(string sUserName, string sPassword, string ReturnUrl) { string loginStatus = _client.DSATReport_Login(sUserName, sPassword); if (loginStatus == "1") { return(Json(new { Status = false, sErrMsg = "用户名不存在`!" })); } else if (loginStatus == "2") { return(Json(new { Status = false, sErrMsg = "密码不正确!" })); } //登陆成功 用户信息放到session中 UserInfoDto userInfo = _client.DSATReport_UserInfoSearch(sUserName); ViewBag.Password = userInfo.Password; if (userInfo != null) { FormsAuthentication.SetAuthCookie(userInfo.UserId, false); Session["LoginUser"] = userInfo; Session["UserId"] = userInfo.UserId; if (userInfo.RoleTypeCode == "Shop") { ReturnUrl = "/Home/ReportTypeSelect"; } return(Json(new { Status = true, sRedirectURL = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) + ReturnUrl })); } else { return(Json(new { Status = false, sErrMsg = "用户信息不存在!" })); } }
/// <summary> /// Updates the specified user in the user database /// </summary> /// <param name="user">User information</param> public async Task UpdateUserAsync(UserInfoDto user) { using (var ctx = DataAccessFactory.CreateContext <ISecurityDataOperations>()) { await ctx.UpdateUserAsync(MapUser(user)); } }
public ActionResult UserLogin([FromBody] UserLoginDto userLogin) { var response = new ResponseDataHelper <UserInfoDto>(); try { var user = _userLogic.GetUserByLoginName(userLogin.LoginName); if (user == null) { response.ResponseCode = -1; response.ResponseMessage = "登录名不存在"; } else if (user.Password != userLogin.Password) { response.ResponseCode = -1; response.ResponseMessage = "密码不正确"; } else { response.ResponseCode = 0; response.ResponseMessage = "登录成功"; response.ResponseData = UserInfoDto.CreateFromUser(user); HttpContext.Session.SetString("CurrentUser", JsonConvert.SerializeObject(user)); } } catch (Exception e) { response.ResponseCode = -1; response.ResponseMessage = e.Message; } return(Json(response)); }
public void SetLoginedUserInfo() { string loginedUserCookie = base.Request.Cookies["current-logined-user-guid"]; if (RunAs.Debug && loginedUserCookie == null) //Debug 环境前端跨域不发送 cookie { this.CurrentUser = new UserInfoDto { Id = 1, AvatarUrl = "/assets/user-avatar/journey.JPG", CreateDate = "2019-07-09 21:51:00.000000", LastModifyDate = "2019-07-09 21:51:00.000000", PersonalHomepageUrl = "https://space.bilibili.com/242720226", IsLoginSuccess = true, UserName = "******", NickName = "虎牙汉界", IsAdmin = true }; return; } if (!string.IsNullOrEmpty(loginedUserCookie)) { UserInfoDto currentUser = null; UserStatuService.LoginedUsers.TryGetValue(loginedUserCookie, out currentUser); this.CurrentUser = currentUser; } }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,CreateTime")] UserInfoDto userInfoDto) { if (id != userInfoDto.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userInfoDto); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserInfoDtoExists(userInfoDto.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userInfoDto)); }
public async Task AddUserToContactsAsync(UserInfoDto model) { if (string.IsNullOrWhiteSpace(model.Login)) { throw new ArgumentException("Login can't be empty"); } if (!EmailProvider.IsValidEmail(model.Login)) { throw new ArgumentException("Login is not a valid email: " + model.Login); } var uri = new Uri(_slackApiLink + "users.admin.invite"); using (HttpClient httpClient = new HttpClient()) { var sendModel = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("token", _slackConfigurations.UserToken), new KeyValuePair <string, string>("email", model.Login) }; using (FormUrlEncodedContent content = new FormUrlEncodedContent(sendModel)) { await httpClient.PostAsync(uri, content); UsersList = null; // Removing previous users list } } }
public void Update_existing_user() { NewUserDto newUserDto = new NewUserDto { Name = "Martin", Surname = "Fowler", Username = "******", Password = "******", Email = "*****@*****.**", IsRoot = false }; UpdateUserDto updatedUserDto = new UpdateUserDto { Name = "John", Surname = "Smith", Username = "******", Password = "******", Email = "*****@*****.**", IsRoot = true }; NewUserIdDto newUserIdDto = _managementController.CreateUser(newUserDto); _managementController.UpdateUser(newUserIdDto.Id, updatedUserDto); UserInfoDto userInfoDto = _managementController.GetUser(newUserIdDto.Id); Assert.AreEqual(updatedUserDto.Name, userInfoDto.Name); Assert.AreEqual(updatedUserDto.Surname, userInfoDto.Surname); Assert.AreEqual(updatedUserDto.Email, userInfoDto.Email); Assert.AreEqual(updatedUserDto.Username, userInfoDto.Username); Assert.AreEqual(updatedUserDto.IsRoot, userInfoDto.IsRoot); }
public UserInfoDto GetTalker(string talkerLogin) { User user = userManager.GetUserByLogin(talkerLogin); UserInfoDto userInfo = mapper.FromUserAuthorDto(user); return(userInfo); }
public async Task <ApiRequestResult> GetAsync() { var token = HttpContext.Request.Headers["Authorization"].ToString(); var key = token.Replace("Bearer", "").Trim(); var jsonRedis = await _cache.GetStringAsync(key); if (jsonRedis.IsNullOrEmpty()) { return(ApiRequestResult.Error("登录已过期", HttpStatusCode.Unauthorized)); } var jsonWebToken = JsonConvert.DeserializeObject <JsonWebToken>(jsonRedis); var accountUser = await _identityServices.GetAsync(Guid.Parse(jsonWebToken.Id)); var roles = new List <string> { "TEST" }; var userInfo = new UserInfoDto { UserName = accountUser.UserName, Roles = roles, }; return(ApiRequestResult.Success(userInfo, "")); }
/// <summary> /// 获取个人基础资料 /// </summary> /// <param name="param"></param> public async Task <UserInfoDto> GetUserInfo(ActiveUserInfoParam param) { return(await Task.Run(async() => { var data = new UserInfoDto(); var xmlStr = XmlHelp.SaveXml(param); if (xmlStr) { int result = WorkersMedicalInsurance.CallService_cxjb("CXJB001"); if (result == 1) { data = XmlHelp.DeSerializerModel(new UserInfoDto()); } else { throw new Exception("居民个人基础资料执行失败!!!"); } } return data; })); }
public ActionResult AddUser([FromBody] AddUserInfoDto userInfo) { var response = new ResponseDataHelper <UserInfoDto>(); try { //var user= var user = _userLogic.GetUserByLoginName(userInfo.LoginName); if (user == null) { user = _userLogic.AddUser(userInfo.ToUser()); response.ResponseData = UserInfoDto.CreateFromUser(user); } else { response.ResponseCode = -1; response.ResponseMessage = "登录名已存在"; } } catch (Exception e) { response.ResponseCode = -1; response.ResponseMessage = e.Message; } return(Json(response)); }
public async Task <ActionResult <ResponseData> > Update(UserInfoDto userInfoDto) { if (userInfoDto != null && userInfoDto.Id > 0) { var userInfo = await _userRepository.Get(userInfoDto.Id, i => i.Include(x => x.Roles).ThenInclude(x => x.Role)); if (userInfo != null) { userInfoDto.MapTo(userInfo); if (userInfoDto.RoleIDS != null && userInfoDto.RoleIDS.Count > 0) { userInfo.Roles = new List <UserInRole>(); userInfoDto.RoleIDS.ForEach(x => userInfo.Roles?.Add(new UserInRole() { RoleId = x, UserId = userInfo.Id })); } var user = await _userInfoService.Update(userInfo); _responseData.Success = true; _responseData.Data = user; } else { _responseData.Success = false; _responseData.Message = "用户不存在"; } } return(_responseData); }
public UserInfoDto GetPostAuthor(int postId) { User author = postManager.GetAuthorByPostId(postId); UserInfoDto authorDto = mapper.FromUserAuthorDto(author); return(authorDto); }
/// <summary> /// 初始化用户初始数据 /// author:陶林辉 /// </summary> /// <param name="user">用户注册数据</param> /// <param name="login">用户登陆信息</param> /// <param name="userInfo">用户信息</param> /// <returns>注册用户uerid</returns> public long Register(RegisterDto user, UserLoginDto login, UserInfoDto userInfo) { using (var vTran = _context.Database.BeginTransaction()) { try { var vRegister = _mapper.Map <RegisterDto, RegisterEntity>(user); var vDbRegister = _context.Register; vDbRegister.Add(vRegister); _context.SaveChanges(); var vLogin = _mapper.Map <UserLoginDto, UserLoginEntity>(login); vLogin.Userid = vRegister.Userid; var vDbLogin = _context.UserLogin; vDbLogin.Add(vLogin); var vUserInfp = _mapper.Map <UserInfoDto, UserInfoEntity>(userInfo); vUserInfp.Userid = vRegister.Userid; var vDbInfo = _context.UserInfo; vDbInfo.Add(vUserInfp); _context.SaveChanges(); vTran.Commit(); //提交事务 return(vRegister.Userid); } catch (global::System.Exception) { vTran.Rollback(); //回滚 return(0); throw; } } }
public JsonResult Post([FromBody] UserInfoDto userInfo) { try { //如果是使用 Cookie 恢复登录状态,装载数据传输模型。 if (userInfo == null && Request.Cookies.ContainsKey(StringTagEnum.CurrentLoginedUserGuid)) { userInfo = new UserInfoDto { StatusMarkGuid = Request.Cookies[StringTagEnum.CurrentLoginedUserGuid] }; } UserInfoDto result = this._userInfoService.UserLoginAutoHandler(userInfo); if (result != null && !string.IsNullOrEmpty(result.StatusMarkGuid)) { base.Response.Cookies.Append(StringTagEnum.CurrentLoginedUserGuid, result.StatusMarkGuid); return(new JsonResult(result)); } return(new JsonResult(new UserInfoDto { IsLoginSuccess = false })); } catch (UnauthorizedAccessException) { return(new JsonResult(new UserInfoDto { IsLoginSuccess = false })); } }
private void SearchUserInfo() { List <UserInfoDto> userInfoList = new List <UserInfoDto>(); DataSet ds = service.SearchUserInfoDto(txtUserID.Text.Trim(), CommonHandler.GetComboBoxSelectedValue(cboRoleType).ToString()); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { UserInfoDto userInfoDto = new UserInfoDto(); userInfoDto.UserID = Convert.ToString(ds.Tables[0].Rows[i]["UserID"]); userInfoDto.RoleType = Convert.ToString(ds.Tables[0].Rows[i]["RoleType"]); userInfoDto.PSW = Convert.ToString(ds.Tables[0].Rows[i]["PSW"]); userInfoList.Add(userInfoDto); } } grcUserInfo.DataSource = userInfoList; this.CSParentForm.EnabelButton(ButtonType.AddRowButton, true); this.CSParentForm.EnabelButton(ButtonType.SaveButton, true); if (grvUserInfo.DataRowCount > 0) { this.CSParentForm.EnabelButton(ButtonType.DeleteRowButton, true); } }
public bool ExcuteUpdateModel(UserInfoDto model) { var newModel = Mapper.Map <MY7W.Domain.Model.UserInfo>(model); //TODO:实现更新个别字段 return(UserInfoRespository.Update(newModel) > 0); }
private void Search(string shopCode, string shopName, string projectCode, UserInfoDto userinfo, string type) { DataSet ds = new DataSet(); if (type == "RecheckUser" && userinfo.RoleType == "R")//复审界面选择经销商,如果是复审人员的话,按照复审设置查询经销商 { ds = webService.SearchShopForRecheckUser(projectCode, shopCode, userinfo.UserID); } else { ds = webService.SearchShop(shopCode, shopName); } List <ShopDto> shoplist = new List <ShopDto>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ShopDto shop = new ShopDto(); //shop.AreaCode = Convert.ToString(ds.Tables[0].Rows[i]["AreaCode"]); //shop.AreaName = Convert.ToString(ds.Tables[0].Rows[i]["AreaName"]); //shop.SaleSmall = Convert.ToString(ds.Tables[0].Rows[i]["SellSmallAreaName"]); //shop.SaleBig = Convert.ToString(ds.Tables[0].Rows[i]["SellBigAreaName"]); //shop.AfterSmall = Convert.ToString(ds.Tables[0].Rows[i]["AfterSmallAreaName"]); //shop.AfterBig = Convert.ToString(ds.Tables[0].Rows[i]["AfterBigAreaName"]); shop.ShopCode = Convert.ToString(ds.Tables[0].Rows[i]["ShopCode"]); shop.ShopName = Convert.ToString(ds.Tables[0].Rows[i]["ShopName"]); shoplist.Add(shop); } } grcShop.DataSource = shoplist; }
public bool ExecuteInsertModel(UserInfoDto model) { try { var insetValue = false; var newModel = Mapper.Map <UserInfoDto, MY7W.Domain.Model.UserInfo>(model); newModel.ID = Guid.NewGuid(); newModel.CreateTime = DateTime.Now; newModel.SysUser = new Domain.RBACModel.SysUser() { ID = Guid.NewGuid(), CreateTime = DateTime.Now, Name = newModel.Name }; insetValue = UserInfoRespository.Insert(newModel) > 0; //if (userInfoServer.Inset(newModel)) //{ // OrderInfoServices orderInfoServices = new OrderInfoServices(); // orderInfoServices.ExecuteInsertModel(new Domain.Model.OrderInfo() { UserInfoId = newModel.Id, Id = Guid.NewGuid(), CreateTime = DateTime.Now }); // //insetValue = orderInfoServer.ExecuteInsetModel(new Domain.Model.OrderInfo() { UserInfoId = newModel.Id, Id = Guid.NewGuid(), CreateTime = DateTime.Now }); //} return(insetValue); } catch (Exception ex) { throw ex; } }
/// <summary> /// Factory method. Loads a <see cref="UserInfo"/> object from the given UserInfoDto. /// </summary> /// <param name="data">The <see cref="UserInfoDto"/>.</param> /// <returns>A reference to the fetched <see cref="UserInfo"/> object.</returns> internal static UserInfo GetUserInfo(UserInfoDto data) { UserInfo obj = new UserInfo(); obj.Fetch(data); return(obj); }
public async Task <JsonResponse> GetUserList(UserInfoDto dto) { JsonResponse response = new JsonResponse(); try { List <Expression <Func <UserInfo, bool> > > expression = new List <Expression <Func <UserInfo, bool> > >(); if (!string.IsNullOrEmpty(dto.Name)) { expression.Add(m => m.Name == dto.Name); } if (!string.IsNullOrEmpty(dto.Pwd)) { expression.Add(m => m.Pwd == dto.Pwd); } if (dto.Status.HasValue) { expression.Add(m => m.Status == dto.Status.Value); } var res = await _userInfoRepository.GetListAsync(expression, dto.pageIndex, dto.pageSize, dto.sortOrder); response.data = res.Item1; response.total = res.Item2; response.msg = "操作成功"; response.code = StatusCodeDefine.Success; } catch (Exception ex) { response.msg = ex.Message; response.code = StatusCodeDefine.ServerError; response.status = -1; } return(response); }
public async Task <ApiResponse> UpdateUser(UserInfoDto userInfo) { if (!ModelState.IsValid) { return(new ApiResponse(400, "User Model is Invalid")); } var user = await _userManager.FindByEmailAsync(userInfo.Email); if (user == null) { _logger.LogInformation("User does not exist: {0}", userInfo.Email); return(new ApiResponse(404, "User does not exist")); } user.FirstName = userInfo.FirstName; user.LastName = userInfo.LastName; var result = await _userManager.UpdateAsync(user); if (!result.Succeeded) { _logger.LogInformation("User Update Failed: {0}", result.Errors.FirstOrDefault()?.Description); return(new ApiResponse(400, "User Update Failed")); } return(new ApiResponse(200, "User Updated Successfully")); }
private async Task SetUserInfo() { try { UserInfoDto userInfo = await ApiHelper.GetUserInfo(); if (userInfo != null) { userInfoDto = userInfo; if (userInfoDto.FotoProfilo != null) { Stream stream = new MemoryStream(userInfo.FotoProfilo); imgFotoUtente.Source = ImageSource.FromStream(() => { return(stream); }); } else if (userInfoDto.PhotoUrl != null) { imgFotoUtente.Source = ImageSource.FromUri(new Uri(userInfoDto.PhotoUrl)); } lblNomeCognome.Text = $"{userInfo.Nome} {userInfo.Cognome}"; lblEmail.Text = userInfo.Email; } } catch (Exception ex) { //Navigo alla pagina d'errore. await Navigation.PushAsync(new NavigationPage(new ErrorPage())); } }
private void BindUserCombox() { string prjectCode = CommonHandler.GetComboBoxSelectedValue(cboProject).ToString(); List <UserInfoDto> list = new List <UserInfoDto>(); DataSet ds = webService.SearchUserInfoAll(prjectCode); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string areaCode = Convert.ToString(ds.Tables[0].Rows[i]["AreaCode"]); string userId = Convert.ToString(ds.Tables[0].Rows[i]["UserId"]); string[] userIdList = userId.Split(';'); foreach (string str in userIdList) { if (!string.IsNullOrEmpty(str)) { UserInfoDto exam = new UserInfoDto(); exam.UserID = str; exam.UserName = str + "(" + areaCode + ")"; if (!list.Contains(exam)) { list.Add(exam); } } } } } CommonHandler.SetComboBoxEditItems(cboUserId, list, "UserName", "UserID"); }
void webService_SearchUserByUserIDCompleted(object sender, XHX.localhost.SearchUserByUserIDCompletedEventArgs e) { this.Enabled = true; DataSet ds = e.Result; UserInfoDto userInfoDto = new UserInfoDto(); if (ds.Tables[0].Rows.Count > 0) { userInfoDto.UserID = Convert.ToString(ds.Tables[0].Rows[0]["UserID"]); userInfoDto.PSW = Convert.ToString(ds.Tables[0].Rows[0]["PSW"]); userInfoDto.RoleType = Convert.ToString(ds.Tables[0].Rows[0]["RoleType"]); } string userID = txtUserID.Text.Trim(); string pwd = txtPWD.Text.Trim(); if (!userID.Equals(userInfoDto.UserID)) { CommonHandler.ShowMessage(MessageType.Information, "Óû§Ãû´íÎó¡£"); return; } if (!pwd.Equals(userInfoDto.PSW)) { CommonHandler.ShowMessage(MessageType.Information, "ÃÜÂë´íÎó¡£"); return; } userInfoDto.IsNetWork = true; MainForm mainForm = new MainForm(); mainForm.UserInfoDto = userInfoDto; mainForm.Show(); this.Hide(); }
public async Task <UserInfoDto> GetUserInfo(long id) { var user = await _userRepository.FetchAsync(u => new { u.Account, u.Avatar, u.Birthday, u.DeptId, Dept = new { u.Dept.FullName }, u.Email, u.ID, u.Name, u.Phone, u.RoleId, u.Sex, u.Status } , x => x.ID == id); UserInfoDto userContext = new UserInfoDto { Name = user.Name, }; userContext.Profile = _mapper.Map <UserProfileDto>(user); userContext.Profile.DeptFullName = user.Dept.FullName; if (!string.IsNullOrWhiteSpace(user.RoleId)) { var roleIds = user.RoleId.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); var roles = await _roleRepository.SelectAsync(r => new { r.ID, r.Tips, r.Name }, x => roleIds.Contains(x.ID)); foreach (var role in roles) { userContext.Roles.Add(role.Tips); userContext.Profile.Roles.Add(role.Name); } var roleMenus = await _menuRepository.GetMenusByRoleIdsAsync(roleIds.ToArray(), true); if (roleMenus.Any()) { userContext.Permissions.AddRange(roleMenus.Select(x => x.Url).Distinct()); } } return(userContext); }
/// <summary> /// 创建ClaimsIdentity /// </summary> /// <param name="user"></param> /// <param name="authenticationType"></param> /// <returns></returns> public ClaimsIdentity CreateIdentity(UserInfoDto user, string authenticationType) { ClaimsIdentity identity = new ClaimsIdentity(authenticationType); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); identity.AddClaim(new Claim(ClaimTypes.Email, user.Email)); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString())); identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity")); identity.AddClaim(new Claim("DisplayName", user.NickName)); return identity; }