mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 07:22:35 -07:00
Added user logout method and unit tests to cover it
This commit is contained in:
parent
55560611e8
commit
759540c837
4 changed files with 51 additions and 6 deletions
|
@ -27,6 +27,7 @@
|
|||
using System.Linq;
|
||||
|
||||
using Nancy;
|
||||
using Nancy.Extensions;
|
||||
using Nancy.Responses.Negotiation;
|
||||
|
||||
using PlexRequests.Api.Interfaces;
|
||||
|
@ -46,6 +47,7 @@ namespace PlexRequests.UI.Modules
|
|||
Api = api;
|
||||
Get["/"] = _ => Index();
|
||||
Post["/"] = x => LoginUser();
|
||||
Get["/logout"] = x => Logout();
|
||||
}
|
||||
|
||||
private ISettingsService<AuthenticationSettings> AuthService { get; }
|
||||
|
@ -104,6 +106,15 @@ namespace PlexRequests.UI.Modules
|
|||
: new JsonResponseModel { Result = false, Message = "Incorrect User or Password"});
|
||||
}
|
||||
|
||||
private Response Logout()
|
||||
{
|
||||
if (Session[SessionKeys.UsernameKey] != null)
|
||||
{
|
||||
Session.Delete(SessionKeys.UsernameKey);
|
||||
}
|
||||
return Context.GetRedirect("~/userlogin");
|
||||
}
|
||||
|
||||
private bool CheckIfUserIsInPlexFriends(string username, string authToken)
|
||||
{
|
||||
var users = Api.GetUsers(authToken);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue