public ActionResult <MessageDTO> GetMessagesForUser([FromHeader] string key) { if (!_authorizationService.AuthorizeUser(key)) { return(StatusCode(StatusCodes.Status401Unauthorized, "User authorization failed!")); } string keyOnly = key[(key.IndexOf("Bearer") + 7)..];
public ActionResult <List <ForumMessageDTO> > GetAllForumMessages([FromHeader] string key) { if (!_authorizationService.AuthorizeUser(key)) { return(StatusCode(StatusCodes.Status401Unauthorized, "User authorization failed!")); } var forumMess = _forumMessageService.GetAllForumMessages(); if (forumMess == null || forumMess.Count == 0) { return(StatusCode(StatusCodes.Status404NotFound, "No forum messages found...")); } logger.LogInformation("Successfully returned list of all messages."); return(Ok(forumMess)); }
public async Task <bool> Login(string email, string password) { var response = await _auth.AuthorizeUser(email, _encryptionHelper.Encrypt(password)); return(response); }