public async Task <ActionResult> LogUserIn([FromBody] AccountLogInDTO userCredentials) { string savedPwd = await _repository.GetPassword(userCredentials.Email); if (savedPwd != null) { if (AuthentificationService.IsPasswordCorrect(savedPwd, userCredentials.Password)) { StudentDTO student = await _repository.StudentExists(userCredentials.Email); student.Student.ProfilePicturePath = FileManagerService.LoadImageFromFile(student.Student.ProfilePicturePath); string token = JwtManager.GenerateJWToken(student.Student, student.Id.ToString()); return(Ok(new JsonResult(token))); } else { return(Ok(new JsonResult("Wrong password"))); } } else { return(Ok(new JsonResult("Non-existent email"))); } }