public async Task <ActionResult <IEnumerable <Walk> > > GetWalks([FromHeader] string token, [FromHeader] string email) { // if not signed in and authenticated if (!(await _safewalkerRepository.Authenticated(token, email))) { return(Unauthorized()); } IEnumerable <Walk> walkList = _walkRepository.GetAll(); return(Ok(walkList)); }
public async Task <IActionResult> PutLogout([FromHeader] string token, [FromHeader] string email, [FromHeader] bool isUser) { // if user and not authenticated if (isUser && !await _userRepository.Authenticated(token, email)) { return(Unauthorized()); } // is safewalker and not authenticated else if (!isUser && !await _safewalkerRepository.Authenticated(token, email)) { return(Unauthorized()); } if (isUser) { var user = await _userRepository.Get(email); user.WithoutTempAuth(); await _userRepository.Update(user); } else { var walker = await _safewalkerRepository.Get(email); walker.WithoutTempAuth(); await _safewalkerRepository.Update(walker); } return(Ok()); }
public async Task <ActionResult <Safewalker> > GetSafewalker([FromHeader] string token, [FromHeader] string email, [FromRoute] string walkerEmail, [FromHeader] bool isUser) { // if user and not authenticated if (isUser && !await _userRepository.Authenticated(token, email)) { return(Unauthorized()); } // is safewalker and not authenticated else if (!isUser && !await _safewalkerRepository.Authenticated(token, email)) { return(Unauthorized()); } var walker = await _safewalkerRepository.Get(walkerEmail); var copyWalker = walker.DeepClone().WithoutPrivateInfo(); return(Ok(copyWalker)); }