@ -71,9 +71,25 @@ namespace PlexRequests.UI.Modules
if ( landingCheck )
{
var landingSettings = await LandingPageSettings . GetSettingsAsync ( ) ;
if ( landingSettings . Enabled )
{
return View [ "Landing/Index" , landingSettings ] ;
if ( landingSettings . BeforeLogin )
{
var model = new LandingPageViewModel
{
Enabled = landingSettings . Enabled ,
Id = landingSettings . Id ,
EnabledNoticeTime = landingSettings . EnabledNoticeTime ,
NoticeEnable = landingSettings . NoticeEnable ,
NoticeEnd = landingSettings . NoticeEnd ,
NoticeMessage = landingSettings . NoticeMessage ,
NoticeStart = landingSettings . NoticeStart ,
ContinueUrl = landingSettings . BeforeLogin ? $"userlogin" : $"search"
} ;
return View [ "Landing/Index" , model ] ;
}
}
}
var settings = await AuthService . GetSettingsAsync ( ) ;
@ -84,7 +100,7 @@ namespace PlexRequests.UI.Modules
{
var dateTimeOffset = Request . Form . DateTimeOffset ;
var username = Request . Form . username . Value ;
Log . Debug ( "Username \"{0}\" attempting to login" , username ) ;
Log . Debug ( "Username \"{0}\" attempting to login" , username ) ;
if ( string . IsNullOrWhiteSpace ( username ) )
{
return Response . AsJson ( new JsonResponseModel { Result = false , Message = "Incorrect User or Password" } ) ;
@ -127,7 +143,7 @@ namespace PlexRequests.UI.Modules
}
}
}
else if ( settings . UserAuthentication ) // Check against the users in Plex
else if ( settings . UserAuthentication ) // Check against the users in Plex
{
Log . Debug ( "Need to auth" ) ;
authenticated = CheckIfUserIsInPlexFriends ( username , settings . PlexAuthToken ) ;
@ -138,7 +154,7 @@ namespace PlexRequests.UI.Modules
}
Log . Debug ( "Friends list result = {0}" , authenticated ) ;
}
else if ( ! settings . UserAuthentication ) // No auth, let them pass!
else if ( ! settings . UserAuthentication ) // No auth, let them pass!
{
Log . Debug ( "No need to auth" ) ;
authenticated = true ;
@ -153,9 +169,19 @@ namespace PlexRequests.UI.Modules
Session [ SessionKeys . ClientDateTimeOffsetKey ] = ( int ) dateTimeOffset ;
return Response . AsJson ( authenticated
? new JsonResponseModel { Result = true }
: new JsonResponseModel { Result = false , Message = "Incorrect User or Password" } ) ;
if ( ! authenticated )
{
return Response . AsJson ( new JsonResponseModel { Result = false , Message = "Incorrect User or Password" } ) ;
}
var landingSettings = LandingPageSettings . GetSettings ( ) ;
if ( landingSettings . Enabled )
{
if ( ! landingSettings . BeforeLogin )
return Response . AsJson ( new JsonResponseModel { Result = true , Message = "landing" } ) ;
}
return Response . AsJson ( new JsonResponseModel { Result = true , Message = "search" } ) ;
}