Browse Source

Merge pull request #71 from colinin/3.0

lastest commit 3.0
pull/81/head
cKey 5 years ago
committed by GitHub
parent
commit
eddea95a82
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      aspnet-core/LINGYUN.MicroService.sln
  2. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IAccountAppService.cs
  3. 10
      aspnet-core/modules/common/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN/Abp/IdentityServer/WeChatValidator/WeChatTokenGrantValidator.cs
  4. 13
      aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs
  5. 3
      aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj
  6. 34
      aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml
  7. 11
      aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml.cs
  8. 4
      aspnet-core/services/account/AuthServer.Host/Pages/_ViewImports.cshtml
  9. 2
      aspnet-core/services/account/AuthServer.Host/package.json
  10. 6
      vueJs/package-lock.json
  11. 1
      vueJs/package.json
  12. 9
      vueJs/src/components/Notification/components/UserNofitications.vue
  13. 14
      vueJs/src/components/Notification/index.vue
  14. 2
      vueJs/src/main.ts

2
aspnet-core/LINGYUN.MicroService.sln

@ -213,7 +213,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.Domain
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.EntityFrameworkCore", "modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj", "{6FE7E243-2D99-4567-8786-6C9283D608EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Domain.Entities.Events", "modules\common\LINGYUN.Abp.Domain.Entities.Events\LINGYUN.Abp.Domain.Entities.Events.csproj", "{AAD8EF65-1FBF-4F3F-8B33-8B76E1EBA4A5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Domain.Entities.Events", "modules\common\LINGYUN.Abp.Domain.Entities.Events\LINGYUN.Abp.Domain.Entities.Events.csproj", "{AAD8EF65-1FBF-4F3F-8B33-8B76E1EBA4A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IAccountAppService.cs

@ -10,7 +10,7 @@ namespace LINGYUN.Abp.Account
Task<IdentityUserDto> RegisterAsync(WeChatRegisterDto input);
Task ResetPasswordAsync(PasswordResetDto passwordReset);
Task ResetPasswordAsync(PasswordResetDto input);
Task VerifyPhoneNumberAsync(VerifyDto input);
}

10
aspnet-core/modules/common/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN/Abp/IdentityServer/WeChatValidator/WeChatTokenGrantValidator.cs

@ -80,11 +80,11 @@ namespace LINGYUN.Abp.IdentityServer.WeChatValidator
Localizer["InvalidGrant:WeChatCodeNotFound"]);
return;
}
var whchatOpenId = await WeChatOpenIdFinder.FindAsync(wechatCode);
var currentUser = await UserManager.FindByLoginAsync("WeChat", whchatOpenId.OpenId);
var wechatOpenId = await WeChatOpenIdFinder.FindAsync(wechatCode);
var currentUser = await UserManager.FindByLoginAsync("WeChat", wechatOpenId.OpenId);
if(currentUser == null)
{
Logger.LogWarning("Invalid grant type: wechat openid: {0} not register", whchatOpenId.OpenId);
Logger.LogWarning("Invalid grant type: wechat openid: {0} not register", wechatOpenId.OpenId);
context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant,
Localizer["InvalidGrant:WeChatNotRegister"]);
return;
@ -96,9 +96,9 @@ namespace LINGYUN.Abp.IdentityServer.WeChatValidator
{
additionalClaims.Add(new Claim(AbpClaimTypes.TenantId, currentUser.TenantId?.ToString()));
}
additionalClaims.Add(new Claim(WeChatValidatorConsts.ClaimTypes.OpenId, whchatOpenId.OpenId));
additionalClaims.Add(new Claim(WeChatValidatorConsts.ClaimTypes.OpenId, wechatOpenId.OpenId));
await EventService.RaiseAsync(new UserLoginSuccessEvent(currentUser.UserName, whchatOpenId.OpenId, null));
await EventService.RaiseAsync(new UserLoginSuccessEvent(currentUser.UserName, wechatOpenId.OpenId, null));
context.Result = new GrantValidationResult(sub,
WeChatValidatorConsts.AuthenticationMethods.BasedWeChatAuthentication, additionalClaims.ToArray());
}

13
aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs

@ -16,7 +16,10 @@ using System;
using System.Linq;
using System.Text;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.Auditing;
using Volo.Abp.Autofac;
using Volo.Abp.Caching;
@ -48,6 +51,9 @@ namespace AuthServer.Host
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpIdentityServerSmsValidatorModule),
typeof(AbpIdentityServerWeChatValidatorModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpEntityFrameworkCoreMySQLModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
@ -73,6 +79,10 @@ namespace AuthServer.Host
})
.UseDashboard();
});
PreConfigure<IIdentityServerBuilder>(builder =>
{
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
@ -179,9 +189,12 @@ namespace AuthServer.Host
app.UseAbpRequestLocalization();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
app.UseMultiTenancy();
app.UseIdentityServer();
app.UseAuthorization();
app.UseAuditing();
app.UseConfiguredEndpoints();
if (context.GetEnvironment().IsDevelopment())
{

3
aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj

@ -20,6 +20,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Account.Application" Version="3.0.0" />
<PackageReference Include="Volo.Abp.Account.Web.IdentityServer" Version="3.0.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="3.0.0" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="3.0.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="3.0.0" />
<PackageReference Include="Volo.Abp.Identity.AspNetCore" Version="3.0.0" />

34
aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml

@ -0,0 +1,34 @@
@page
@using AuthServer.Host.Pages
@using Volo.Abp.Users
@model IndexModel
@inject ICurrentUser CurrentUser
@if (CurrentUser.IsAuthenticated)
{
<div>
<abp-row>
<abp-column size-md="_3" class="text-center">
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i>
<a abp-button="Primary" href="/Account/Logout">Logout</a>
</abp-column>
<abp-column size-md="_9">
<h2>@CurrentUser.UserName</h2>
<h5 class="text-muted">@CurrentUser.Email</h5>
<div>
<strong>Roles</strong>: @CurrentUser.Roles.JoinAsString(", ")
<br />
<strong>Claims</strong>: <br />
@Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString(" <br /> "))
</div>
</abp-column>
</abp-row>
</div>
}
@if (!CurrentUser.IsAuthenticated)
{
<div class="text-center">
<i class="fa fa-user d-block" style="font-size: 10em; color: #aaa"></i><br /><br />
<a abp-button="Primary" asp-page="/Account/Login">Login</a>
</div>
}

11
aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml.cs

@ -0,0 +1,11 @@
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace AuthServer.Host.Pages
{
public class IndexModel : AbpPageModel
{
public void OnGet()
{
}
}
}

4
aspnet-core/services/account/AuthServer.Host/Pages/_ViewImports.cshtml

@ -0,0 +1,4 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling

2
aspnet-core/services/account/AuthServer.Host/package.json

@ -3,6 +3,6 @@
"name": "my-app-identityserver",
"private": true,
"dependencies": {
"@abp/aspnetcore.mvc.ui.theme.basic": "^2.6.2"
"@abp/aspnetcore.mvc.ui.theme.basic": "3.0.0"
}
}

6
vueJs/package-lock.json

@ -21314,6 +21314,12 @@
}
}
},
"vue-events": {
"version": "3.1.0",
"resolved": "https://registry.npm.taobao.org/vue-events/download/vue-events-3.1.0.tgz",
"integrity": "sha1-jiMSHDRbT/Mu4FT5eVmV8+NEsn0=",
"dev": true
},
"vue-hot-reload-api": {
"version": "2.3.4",
"resolved": "https://registry.npm.taobao.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.4.tgz",

1
vueJs/package.json

@ -117,6 +117,7 @@
"typescript": "^3.8.3",
"vue-cli-plugin-element": "^1.0.1",
"vue-cli-plugin-style-resources-loader": "^0.1.4",
"vue-events": "^3.1.0",
"vue-template-compiler": "^2.6.11",
"vue-virtual-scroll-list": "^2.1.8",
"webpack": "^4.42.1"

9
vueJs/src/components/Notification/components/UserNofitications.vue

@ -113,7 +113,7 @@ export default class extends Vue {
notification.datetime = notify.creationTime
notification.severity = notify.notificationSeverity
this.notifications.push(notification)
this.$emit('notificationReceived')
this.$events.emit('onNotificationReceived', notify)
})
})
})
@ -129,16 +129,14 @@ export default class extends Vue {
private onNotificationReceived(notify: any) {
console.log('received signalr message...')
console.log(notify)
const notification = new Notification()
notification.id = notify.id
notification.title = notify.data.properties.title
notification.message = notify.data.properties.message
notification.datetime = notify.creationTime
notification.severity = notify.notificationSeverity
console.log(notification)
this.pushUserNotification(notification)
this.$emit('notificationReceived')
this.$events.emit('onNotificationReceived', notify)
this.$notify({
title: notification.title,
message: notification.message,
@ -150,12 +148,11 @@ export default class extends Vue {
this.connection.invoke('ChangeState', notificationId, ReadState.Read).then(() => {
const removeNotifyIndex = this.notifications.findIndex(n => n.id === notificationId)
this.notifications.splice(removeNotifyIndex, 1)
this.$emit('notificationReadChanged')
this.$events.emit('onNotificationReadChanged')
})
}
private pushUserNotification(notification: any) {
console.log(this.notifications)
if (this.notifications.length === 20) {
this.notifications.shift()
}

14
vueJs/src/components/Notification/index.vue

@ -21,10 +21,7 @@
<el-tab-pane
label="通知"
>
<user-nofitications
@notificationReceived="notificationCount+=1"
@notificationReadChanged="notificationCount-=1"
/>
<user-nofitications />
</el-tab-pane>
<el-tab-pane label="消息">
{{ $t('messages.noMessages') }}
@ -47,6 +44,15 @@ import UserNofitications from './components/UserNofitications.vue'
})
export default class extends Vue {
private notificationCount = 0
created() {
this.$events.on('onNotificationReceived', () => {
this.notificationCount += 1
})
this.$events.on('onNotificationReadChanged', () => {
this.notificationCount -= 1
})
}
}
</script>

2
vueJs/src/main.ts

@ -7,6 +7,7 @@ import SvgIcon from 'vue-svgicon'
import uploader from 'vue-simple-uploader'
import contextMenu from 'vue-contextmenujs'
import VueEvents from 'vue-events'
import '@/styles/element-variables.scss'
import 'view-design/dist/styles/iview.css'
@ -42,6 +43,7 @@ Vue.use(SvgIcon, {
Vue.use(uploader)
Vue.use(contextMenu)
Vue.use(VueEvents)
// Register global directives
Object.keys(directives).forEach(key => {

Loading…
Cancel
Save