本文整理汇总了C#中IAuthSession.AddAuthToken方法的典型用法代码示例。如果您正苦于以下问题:C# IAuthSession.AddAuthToken方法的具体用法?C# IAuthSession.AddAuthToken怎么用?C# IAuthSession.AddAuthToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAuthSession
的用法示例。
在下文中一共展示了IAuthSession.AddAuthToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
protected IAuthTokens Init(IServiceBase authService, ref IAuthSession session, Authenticate request)
{
var requestUri = authService.Request.AbsoluteUri;
if (this.CallbackUrl.IsNullOrEmpty())
{
this.CallbackUrl = requestUri;
}
if (session.ReferrerUrl.IsNullOrEmpty())
{
session.ReferrerUrl = (request != null ? request.Continue : null) ?? authService.Request.GetHeader("Referer");
}
if (session.ReferrerUrl.IsNullOrEmpty() || session.ReferrerUrl.IndexOf("/auth", StringComparison.OrdinalIgnoreCase) >= 0)
{
session.ReferrerUrl = this.RedirectUrl
?? HttpHandlerFactory.GetBaseUrl()
?? requestUri.Substring(0, requestUri.IndexOf("/", "https://".Length + 1, StringComparison.Ordinal));
}
var tokens = session.GetAuthTokens(this.Provider);
if (tokens == null)
{
session.AddAuthToken(tokens = new AuthTokens { Provider = this.Provider });
}
return tokens;
}
示例2: Init
/// <summary>
/// Sets the CallbackUrl and session.ReferrerUrl if not set and initializes the session tokens for this AuthProvider
/// </summary>
/// <param name="authService"></param>
/// <param name="session"></param>
/// <param name="request"> </param>
/// <returns></returns>
protected IAuthTokens Init(IServiceBase authService, ref IAuthSession session, Authenticate request)
{
if (this.CallbackUrl.IsNullOrEmpty())
this.CallbackUrl = authService.Request.AbsoluteUri;
session.ReferrerUrl = GetReferrerUrl(authService, session, request);
var tokens = session.GetAuthTokens(Provider);
if (tokens == null)
session.AddAuthToken(tokens = new AuthTokens { Provider = Provider });
return tokens;
}