mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 07:22:35 -07:00
done #318
This commit is contained in:
parent
e8706354b9
commit
3e16d8acf0
18 changed files with 399 additions and 57 deletions
|
@ -23,64 +23,19 @@
|
|||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
using System.Linq;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
using Nancy;
|
||||
using Nancy.Extensions;
|
||||
using PlexRequests.UI.Models;
|
||||
using System;
|
||||
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Helpers;
|
||||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
public abstract class BaseAuthModule : BaseModule
|
||||
{
|
||||
private string _username;
|
||||
private int _dateTimeOffset = -1;
|
||||
|
||||
protected string Username
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_username))
|
||||
{
|
||||
_username = Session[SessionKeys.UsernameKey].ToString();
|
||||
}
|
||||
return _username;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool IsAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Context.CurrentUser == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var claims = Context.CurrentUser.Claims.ToList();
|
||||
return claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser);
|
||||
}
|
||||
}
|
||||
|
||||
protected int DateTimeOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dateTimeOffset == -1)
|
||||
{
|
||||
_dateTimeOffset = (int?)Session[SessionKeys.ClientDateTimeOffsetKey] ?? new DateTimeOffset().Offset.Minutes;
|
||||
}
|
||||
return _dateTimeOffset;
|
||||
}
|
||||
}
|
||||
|
||||
protected BaseAuthModule(ISettingsService<PlexRequestSettings> pr) : base(pr)
|
||||
{
|
||||
PlexRequestSettings = pr;
|
||||
|
@ -101,7 +56,7 @@ namespace PlexRequests.UI.Modules
|
|||
var baseUrl = settings.BaseUrl;
|
||||
|
||||
var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin";
|
||||
|
||||
|
||||
return Session[SessionKeys.UsernameKey] == null
|
||||
? Context.GetRedirect(redirectPath)
|
||||
: null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue