Skip to content

Commit

Permalink
InitInit
Browse files Browse the repository at this point in the history
  • Loading branch information
KawhiWei committed May 18, 2021
1 parent 404b153 commit f742cef
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.QQ" Version="2.0.1" />
<PackageReference Include="AspNet.Security.OAuth.QQ" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.4" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.13" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace IdentityServerHost.Quickstart.UI
Expand Down Expand Up @@ -172,7 +173,7 @@ public async Task<IActionResult> Login(LoginInputModel model, string button)
}
else if (string.IsNullOrEmpty(model.ReturnUrl))
{
return Redirect("~/");
return Redirect("/Home/Index");
}
else
{
Expand Down Expand Up @@ -374,5 +375,28 @@ private async Task<LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logou

return vm;
}

/// <summary>
/// 打开qq授权页面
/// </summary>
/// <returns></returns>
public virtual IActionResult QQAuthorize()
{
var appId = "101945230";
var url = string.Format("https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id={0}&redirect_uri={1}&state=State", appId, WebUtility.UrlEncode("http://localhost:50001/signin-qq"));
return new RedirectResult(url);
}
/// <summary>
/// QQ回掉方法
/// </summary>
/// <returns></returns>
public virtual IActionResult QQCallbackLogin()
{
//var code = Request.Query["code"];
//var token = GetAuthorityAccessToken(code);
//var dis = GetAuthorityOpendIdAndUnionId(token);
//var userInfo = GetUserInfo(token, dis["openid"]);
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Destiny.Core.Flow.Model.Entities.Identity;
using Destiny.Core.Flow.Model.Security;
using Microsoft.AspNetCore.Authentication.QQ;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using System;
Expand All @@ -17,11 +16,11 @@ public class IdentityModule : IdentityModuleBase<UserStore, RoleStore, User, Use
{
protected override void AddAuthentication(IServiceCollection services)
{
//services.AddAuthentication().AddQQ(x =>
//{

// x.AppId
//});
services.AddAuthentication().AddQQ(x =>
{
x.ClientId = "adasdasd";
x.ClientSecret = "asdasdadas";
});
}

protected override Action<IdentityOptions> IdentityOption()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>

<div class="form-style-agile">
<img class="image-po" src="~/Connect_logo_5.png" />
<a asp-controller="Account" asp-action="QQAuthorize">QQ<img class="image-po" src="~/Connect_logo_5.png" /></a>
</div>
<button class="button-sub" name="button" value="login">登录</button>
</form>
Expand All @@ -55,7 +55,7 @@
<li class="list-inline-item">
<a class="btn btn-secondary"
asp-controller="External"
asp-action="Challenge"
asp-action="QQAuthorize"
asp-route-scheme="@provider.AuthenticationScheme"
asp-route-returnUrl="@Model.ReturnUrl">
@provider.DisplayName
Expand Down

0 comments on commit f742cef

Please sign in to comment.