1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-29 11:05:44 +00:00

Logout button for forms Auth and fix UrlBase redirects

This commit is contained in:
Mark McDowall 2015-02-03 08:37:42 -08:00
parent aa9df49ea2
commit 754c1ea331
5 changed files with 33 additions and 13 deletions

View file

@ -4,17 +4,21 @@
using Nancy.Extensions;
using Nancy.ModelBinding;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Api.Authentication
{
public class LoginModule : NancyModule
public class AuthenticationModule : NancyModule
{
private readonly IUserService _userService;
private readonly IConfigFileProvider _configFileProvider;
public LoginModule(IUserService userService)
public AuthenticationModule(IUserService userService, IConfigFileProvider configFileProvider)
{
_userService = userService;
_configFileProvider = configFileProvider;
Post["/login"] = x => Login(this.Bind<LoginResource>());
Get["/logout"] = x => Logout();
}
private Response Login(LoginResource resource)
@ -35,5 +39,10 @@ private Response Login(LoginResource resource)
return this.LoginAndRedirect(user.Identifier, expiry);
}
private Response Logout()
{
return this.LogoutAndRedirect(_configFileProvider.UrlBase + "/");
}
}
}

View file

@ -64,7 +64,7 @@ private void RegisterFormsAuth(IPipelines pipelines)
FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration
{
RedirectUrl = "~/login",
RedirectUrl = _configFileProvider.UrlBase + "/login",
UserMapper = _authenticationService,
CryptographyConfiguration = cryptographyConfiguration
});

View file

@ -83,7 +83,7 @@
</Compile>
<Compile Include="Authentication\AuthenticationService.cs" />
<Compile Include="Authentication\EnableAuthInNancy.cs" />
<Compile Include="Authentication\LoginModule.cs" />
<Compile Include="Authentication\AuthenticationModule.cs" />
<Compile Include="Authentication\LoginResource.cs" />
<Compile Include="Authentication\NzbDroneUser.cs" />
<Compile Include="Blacklist\BlacklistModule.cs" />

View file

@ -1,4 +1,4 @@
var $ = require('jquery');
var $ = require('jquery');
var Backbone = require('backbone');
var Marionette = require('marionette');
var SystemInfoLayout = require('./Info/SystemInfoLayout');
@ -7,6 +7,7 @@ var UpdateLayout = require('./Update/UpdateLayout');
var BackupLayout = require('./Backup/BackupLayout');
var TaskLayout = require('./Task/TaskLayout');
var Messenger = require('../Shared/Messenger');
var StatusModel = require('./StatusModel');
module.exports = Marionette.Layout.extend({
template : 'System/SystemLayoutTemplate',
@ -25,18 +26,22 @@ module.exports = Marionette.Layout.extend({
tasksTab : '.x-tasks-tab'
},
events : {
"click .x-info-tab" : '_showInfo',
"click .x-logs-tab" : '_showLogs',
"click .x-updates-tab" : '_showUpdates',
"click .x-backup-tab" : '_showBackup',
"click .x-tasks-tab" : '_showTasks',
"click .x-shutdown" : '_shutdown',
"click .x-restart" : '_restart'
'click .x-info-tab' : '_showInfo',
'click .x-logs-tab' : '_showLogs',
'click .x-updates-tab' : '_showUpdates',
'click .x-backup-tab' : '_showBackup',
'click .x-tasks-tab' : '_showTasks',
'click .x-shutdown' : '_shutdown',
'click .x-restart' : '_restart'
},
initialize : function(options){
if(options.action) {
this.action = options.action.toLowerCase();
}
this.templateHelpers = {
authentication : StatusModel.get('authentication')
};
},
onShow : function(){
switch (this.action) {

View file

@ -1,4 +1,4 @@
<ul class="nav nav-tabs">
<ul class="nav nav-tabs">
<li><a href="#info" class="x-info-tab no-router">Info</a></li>
<li><a href="#logs" class="x-logs-tab no-router">Logs</a></li>
<li><a href="#updates" class="x-updates-tab no-router">Updates</a></li>
@ -12,6 +12,12 @@
<button class="btn btn-default btn-icon-only x-restart" title="Restart" data-container="body">
<i class="icon-nd-restart"></i>
</button>
{{#if_eq authentication compare="forms"}}
<a href="{{UrlBase}}/logout" class="btn btn-default btn-icon-only" title="Logout" data-container="body">
<i class="icon-lock"></i>
</a>
{{/if_eq}}
</div>
</li>
</ul>