@*******************************************************************************************************
// UserInfo.cshtml - Gbtc
//
// Copyright © 2017, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 08/24/2017 - J. Ritchie Carroll
// Generated original version of source code.
//
//*****************************************************************************************************@
@using System.Net.Http
@using System.Net.Http.Headers
@using System.Threading
@using GSF.Security
@using GSF.Identity
@using GSF.Web.Model
@using GSF.Web.Shared
@inherits ExtendedTemplateBase
@{
HttpRequestMessage request = ViewBag.Request;
AuthenticationHeaderValue authHeader = request.Headers.Authorization;
string authScheme;
if ((object)authHeader == null || string.IsNullOrWhiteSpace(authHeader.Scheme)) {
authScheme = "Anonymous";
}
else {
authScheme = authHeader.Scheme;
}
string securityPrincipalType = "Undefined";
if (ViewBag.SecurityPrincipal != null) {
securityPrincipalType = ViewBag.SecurityPrincipal.GetType().Name;
}
}
@functions {
public string GetCurrentUserID()
{
if (Thread.CurrentPrincipal.Identity == null)
return UserInfo.CurrentUserID;
return Thread.CurrentPrincipal.Identity.Name;
}
public bool UserIsAdmin()
{
SecurityPrincipal securityPrincipal = ViewBag.SecurityPrincipal as SecurityPrincipal;
if ((object)securityPrincipal == null)
return false;
return securityPrincipal.IsInRole("Administrator");
}
}
User Information
User Information
| Requested URI: |
@Raw(request.RequestUri.AbsolutePath.Replace("%40", "@")) |
| Requested Authorization Scheme: |
@authScheme |
| Identified User ID: |
@GetCurrentUserID() |
| User Has Admin Role: |
@UserIsAdmin() |
| Security Principal Type: |
@securityPrincipalType |