private async Task ValidateForumUser(HttpContext context, string userName, string password, string successUrl, string failUrl, bool refreshFlag) { var roleClaims = new List <string>(); ClaimsIdentity identity = null; var forumUser = await _forumDal.GetForumUserById(null, userName); if (forumUser != null && (refreshFlag || Security.EncryptAndCompare(password, forumUser.Password))) { if (!forumUser.BanFlag) { roleClaims.Add("ForumUser"); if (forumUser.AdminFlag) { roleClaims.Add("ForumAdmin"); } } else { roleClaims.Add("ForumBanned"); } identity = await GetIdentity(forumUser.Guid.ToString(), userName, "Forum", roleClaims.ToArray()); } await GenerateToken(context, identity, forumUser?.Guid.ToString(), Settings.Current.TimeLimitForumToken, successUrl, failUrl, refreshFlag); }
public async Task <ForumUserModel> GetForumUserById(Guid?guid, string userId, Guid forumUserGuid, bool isForumAdmin) { var forumUser = await _forumDal.GetForumUserById(guid, userId); return((forumUser == null || isForumAdmin || forumUser.Guid == forumUserGuid) ? forumUser : null); }