using Bootstrap.Client.DataAccess;
using Longbow.Configuration;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Authentication.Cookies;
using System;
using System.Security.Principal;
namespace Bootstrap.Client.Models
{
///
///
///
public class HeaderBarModel : ModelBase
{
///
///
///
///
public HeaderBarModel(IIdentity identity)
{
var user = UserHelper.RetrieveUserByUserName(identity.Name);
DisplayName = user.DisplayName;
UserName = user.UserName;
SettingsUrl = DictHelper.RetrieveSettingsUrl();
ProfilesUrl = DictHelper.RetrieveProfilesUrl();
NotisUrl = DictHelper.RetrieveNotisUrl();
// set LogoutUrl
var authHost = ConfigurationManager.Get().AuthHost;
var uriBuilder = new UriBuilder(authHost);
uriBuilder.Path = uriBuilder.Path == "/" ? CookieAuthenticationDefaults.LogoutPath.Value : $"{uriBuilder.Path.TrimEnd('/')}{CookieAuthenticationDefaults.LogoutPath.Value}";
LogoutUrl = uriBuilder.ToString();
// set Icon
var icon = $"/{DictHelper.RetrieveIconFolderPath().Trim('~', '/')}/{user.Icon}";
Icon = $"{authHost.TrimEnd('/')}{icon}";
if (!string.IsNullOrEmpty(user.Css)) Theme = user.Css;
}
///
///
///
public string UserName { get; }
///
///
///
public string DisplayName { get; }
///
/// 获得/设置 用户头像地址
///
public string Icon { get; }
///
/// 获得/设置 设置网址
///
public string SettingsUrl { get; }
///
/// 获得/设置 个人中心网址
///
public string ProfilesUrl { get; }
///
/// 获得 退出登录地址
///
public string LogoutUrl { get; }
///
///
///
public string NotisUrl { get; }
}
}