Changed how login page works based on user feedback. By default, we have the old login flow when authentication is enabled and in addition, we will auto fill the username based on last login on device. (#621)

This commit is contained in:
Joseph Milazzo 2021-10-02 11:35:38 -07:00 committed by GitHub
parent 34d171f0b4
commit 30a302bf99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 14 deletions

View file

@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc;
namespace API.Controllers
{
[Authorize]
public class UsersController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;
@ -42,11 +43,15 @@ namespace API.Controllers
[HttpGet("names")]
public async Task<ActionResult<IEnumerable<MemberDto>>> GetUserNames()
{
var setting = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
if (setting.EnableAuthentication)
{
return Unauthorized("This API cannot be used given your server's configuration");
}
var members = await _unitOfWork.UserRepository.GetMembersAsync();
return Ok(members.Select(m => m.Username));
}
[Authorize]
[HttpGet("has-reading-progress")]
public async Task<ActionResult<bool>> HasReadingProgress(int libraryId)
{
@ -55,7 +60,6 @@ namespace API.Controllers
return Ok(await _unitOfWork.AppUserProgressRepository.UserHasProgress(library.Type, userId));
}
[Authorize]
[HttpGet("has-library-access")]
public async Task<ActionResult<bool>> HasLibraryAccess(int libraryId)
{
@ -63,7 +67,6 @@ namespace API.Controllers
return Ok(libs.Any(x => x.Id == libraryId));
}
[Authorize]
[HttpPost("update-preferences")]
public async Task<ActionResult<UserPreferencesDto>> UpdatePreferences(UserPreferencesDto preferencesDto)
{