From ef6b9fa1d8682d1bdd4802d6791aed7bd55f303f Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Sat, 29 Aug 2020 10:10:53 +0800 Subject: [PATCH 1/3] introducing vue-events as an event bus --- vueJs/package-lock.json | 6 ++++++ vueJs/package.json | 1 + .../Notification/components/UserNofitications.vue | 9 +++------ vueJs/src/components/Notification/index.vue | 14 ++++++++++---- vueJs/src/main.ts | 2 ++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/vueJs/package-lock.json b/vueJs/package-lock.json index be3cf43d6..ba0978c00 100644 --- a/vueJs/package-lock.json +++ b/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", diff --git a/vueJs/package.json b/vueJs/package.json index e5f50de33..e17da4654 100644 --- a/vueJs/package.json +++ b/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" diff --git a/vueJs/src/components/Notification/components/UserNofitications.vue b/vueJs/src/components/Notification/components/UserNofitications.vue index c0b14ba73..a40ca1b74 100644 --- a/vueJs/src/components/Notification/components/UserNofitications.vue +++ b/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() } diff --git a/vueJs/src/components/Notification/index.vue b/vueJs/src/components/Notification/index.vue index 827ea7ea1..37d4f5756 100644 --- a/vueJs/src/components/Notification/index.vue +++ b/vueJs/src/components/Notification/index.vue @@ -21,10 +21,7 @@ - + {{ $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 + }) + } } diff --git a/vueJs/src/main.ts b/vueJs/src/main.ts index fdee7340a..2ac3aa9b5 100644 --- a/vueJs/src/main.ts +++ b/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 => { From e072d1bde8eaaf417db5fd4e3ac4c285223ca41b Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 3 Sep 2020 10:52:50 +0800 Subject: [PATCH 2/3] auth-server adds the default ui theme --- aspnet-core/LINGYUN.MicroService.sln | 2 +- .../LINGYUN/Abp/Account/IAccountAppService.cs | 2 +- .../AuthIdentityServerModule.cs | 7 ++++ .../AuthServer.Host/AuthServer.Host.csproj | 3 ++ .../AuthServer.Host/Pages/Index.cshtml | 34 +++++++++++++++++++ .../AuthServer.Host/Pages/Index.cshtml.cs | 11 ++++++ .../AuthServer.Host/Pages/_ViewImports.cshtml | 4 +++ 7 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml create mode 100644 aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml.cs create mode 100644 aspnet-core/services/account/AuthServer.Host/Pages/_ViewImports.cshtml diff --git a/aspnet-core/LINGYUN.MicroService.sln b/aspnet-core/LINGYUN.MicroService.sln index bf559bea3..0bd523190 100644 --- a/aspnet-core/LINGYUN.MicroService.sln +++ b/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 diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IAccountAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IAccountAppService.cs index d0aa0cd5d..25d36948a 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IAccountAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IAccountAppService.cs @@ -10,7 +10,7 @@ namespace LINGYUN.Abp.Account Task RegisterAsync(WeChatRegisterDto input); - Task ResetPasswordAsync(PasswordResetDto passwordReset); + Task ResetPasswordAsync(PasswordResetDto input); Task VerifyPhoneNumberAsync(VerifyDto input); } diff --git a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs index b28fc772c..9966fd96d 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs +++ b/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), @@ -182,6 +188,7 @@ namespace AuthServer.Host app.UseMultiTenancy(); app.UseIdentityServer(); app.UseAuditing(); + app.UseConfiguredEndpoints(); if (context.GetEnvironment().IsDevelopment()) { diff --git a/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj b/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj index 63fa249bc..b0e96ac14 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj +++ b/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj @@ -20,6 +20,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml b/aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml new file mode 100644 index 000000000..26827322b --- /dev/null +++ b/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) +{ +
+ + + + Logout + + +

@CurrentUser.UserName

+
@CurrentUser.Email
+
+ Roles: @CurrentUser.Roles.JoinAsString(", ") +
+ Claims:
+ @Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString("
")) +
+
+
+
+} + +@if (!CurrentUser.IsAuthenticated) +{ +
+

+ Login +
+} \ No newline at end of file diff --git a/aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml.cs b/aspnet-core/services/account/AuthServer.Host/Pages/Index.cshtml.cs new file mode 100644 index 000000000..869bcc63e --- /dev/null +++ b/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() + { + } + } +} diff --git a/aspnet-core/services/account/AuthServer.Host/Pages/_ViewImports.cshtml b/aspnet-core/services/account/AuthServer.Host/Pages/_ViewImports.cshtml new file mode 100644 index 000000000..9b3b6b819 --- /dev/null +++ b/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 From 000be3acf6100e40ce19968886d20f2a05daa3bd Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 8 Sep 2020 08:42:30 +0800 Subject: [PATCH 3/3] upgrade abp npm package --- .../WeChatValidator/WeChatTokenGrantValidator.cs | 10 +++++----- .../AuthServer.Host/AuthIdentityServerModule.cs | 6 ++++++ .../services/account/AuthServer.Host/package.json | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN/Abp/IdentityServer/WeChatValidator/WeChatTokenGrantValidator.cs b/aspnet-core/modules/common/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN/Abp/IdentityServer/WeChatValidator/WeChatTokenGrantValidator.cs index 3f3485552..9c298699c 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN/Abp/IdentityServer/WeChatValidator/WeChatTokenGrantValidator.cs +++ b/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()); } diff --git a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs index 9966fd96d..158d89a7b 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs +++ b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs @@ -79,6 +79,10 @@ namespace AuthServer.Host }) .UseDashboard(); }); + + PreConfigure(builder => + { + }); } public override void ConfigureServices(ServiceConfigurationContext context) @@ -185,8 +189,10 @@ namespace AuthServer.Host app.UseAbpRequestLocalization(); app.UseRouting(); app.UseCors(DefaultCorsPolicyName); + app.UseAuthentication(); app.UseMultiTenancy(); app.UseIdentityServer(); + app.UseAuthorization(); app.UseAuditing(); app.UseConfiguredEndpoints(); diff --git a/aspnet-core/services/account/AuthServer.Host/package.json b/aspnet-core/services/account/AuthServer.Host/package.json index 412aab56a..288627147 100644 --- a/aspnet-core/services/account/AuthServer.Host/package.json +++ b/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" } }