/// <summary> /// 获取登录用户,如未登录返回null /// </summary> public static GhostUser Get() { LoginToken token = GetLoginToken(); if (token == null) { return(null); } long?id = token.LoginId.ToLong(); if (!id.HasValue) { return(null); } GhostUser user = IocContainer.Get <IGhostUserDao>().SelectByIdReq(id.Value); if (user == null) { return(null); } if (user.IsDisabled) { return(null); } return(user); }
private int GetNewUserIdForPostAuthor(BlogMLAuthorReference authorRef) { if (AssignAllToOneUser) { return(OneUserId); } var userMatches = ghostDoc.data.users.Where(user => user.name.ToLower() == authorRef.Ref.ToLower()); if (!userMatches.Any()) { var newUser = new GhostUser { id = GreatestExistingUserId + ghostDoc.data.users.Count + 1, name = authorRef.Ref, slug = authorRef.Ref.AsSlug(GhostConstants.maxSlugLength), status = GhostUserStatus.disabled, locale = new CultureInfo("en-GB"), visibility = GhostVisibility.@private, last_seen = DateTime.UtcNow, created_at = DateTime.UtcNow, created_by = 1, updated_at = DateTime.UtcNow, updated_by = 1 }; ghostDoc.data.users.Add(newUser); return(newUser.id); } return(userMatches.First().id); }
public static string Login(string mobile, string password, string isrember) { string result; GhostUser user = IocContainer.Get <IGhostUserDao>().SelectTop1(new GhostUserCondition { Mobile = mobile.Trim() }); if (user == null) { return(result = "不存在此手机号"); } if (user.PassWord != password.Trim()) { return(result = "密码错误"); } if (user.IsDisabled) { return(result = "用户已被禁用"); } //创建登录令牌 Auth.Login(user, isrember.ToBoolReq()); return("True"); }
/// <summary> /// 登录 /// </summary> /// <param name="user">用户</param> /// <param name="isRember">是否记住令牌</param> public static void Login(GhostUser user, bool isRember) { Login(ActorDefine.ACTOR_TYPE_USER, user.Id.ToString(), isRember); }