Skip to content

Commit

Permalink
Merge pull request #887 from colinin/resolve-some-problems
Browse files Browse the repository at this point in the history
Resolve some problems
  • Loading branch information
colinin committed Oct 9, 2023
2 parents 07f2daa + 9f275dc commit 574802e
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class UserIdentifier
/// </summary>
public string UserName { get; set; }

public UserIdentifier()
{

}

public UserIdentifier(Guid userId, string userName)
{
UserId = userId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ public async Task ValidateAsync(ExtensionGrantValidationContext context)

await EventService.RaiseAsync(new UserLoginSuccessEvent(currentUser.UserName, phoneNumber, null));

// 登录之后需要更新安全令牌
(await UserManager.UpdateSecurityStampAsync(currentUser)).CheckErrors();

await SetSuccessResultAsync(context, currentUser);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ public async virtual Task ValidateAsync(ExtensionGrantValidationContext context)

await EventService.RaiseAsync(new UserLoginSuccessEvent(AbpWeChatWorkGlobalConsts.ProviderName, userInfo.UserId, null));

// 登录之后需要更新安全令牌
(await UserManager.UpdateSecurityStampAsync(currentUser)).CheckErrors();

await SetSuccessResultAsync(context, currentUser);
}
catch (AbpWeChatWorkException wwe)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ public async virtual Task<IActionResult> HandleAsync(ExtensionGrantContext conte
return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
}

(await userManager.UpdateSecurityStampAsync(currentUser)).CheckErrors();

return await SetSuccessResultAsync(context, currentUser, logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ protected async virtual Task<IActionResult> HandleWeChatAsync(ExtensionGrantCont
return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
}

// 登录之后需要更新安全令牌
(await userManager.UpdateSecurityStampAsync(currentUser)).CheckErrors();

return await SetSuccessResultAsync(context, currentUser, userInfo.UserId, logger);
}
catch (AbpWeChatWorkException wwe)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ protected async virtual Task<IActionResult> HandleWeChatAsync(ExtensionGrantCont
return Forbid(properties, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
}

// 登录之后需要更新安全令牌
(await userManager.UpdateSecurityStampAsync(currentUser)).CheckErrors();

return await SetSuccessResultAsync(context, currentUser, wechatOpenId, logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<ProjectReference Include="..\..\settings\LINGYUN.Abp.SettingManagement.Application.Contracts\LINGYUN.Abp.SettingManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.WeChat.MiniProgram\LINGYUN.Abp.WeChat.MiniProgram.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.WeChat.Official\LINGYUN.Abp.WeChat.Official.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.WeChat.Work\LINGYUN.Abp.WeChat.Work.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using LINGYUN.Abp.WeChat.Localization;
using LINGYUN.Abp.WeChat.MiniProgram;
using LINGYUN.Abp.WeChat.Official;
using LINGYUN.Abp.WeChat.Work;
using LINGYUN.Abp.WeChat.Work.Localization;
using Localization.Resources.AbpUi;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc;
Expand All @@ -13,6 +15,7 @@ namespace LINGYUN.Abp.WeChat.SettingManagement
[DependsOn(
typeof(AbpWeChatOfficialModule),
typeof(AbpWeChatMiniProgramModule),
typeof(AbpWeChatWorkModule),
typeof(AbpAspNetCoreMvcModule))]
public class AbpWeChatSettingManagementModule : AbpModule
{
Expand Down Expand Up @@ -43,7 +46,8 @@ public override void ConfigureServices(ServiceConfigurationContext context)
options.Resources
.Get<WeChatResource>()
.AddBaseTypes(
typeof(AbpUiResource)
typeof(AbpUiResource),
typeof(WeChatWorkResource)
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"culture": "en",
"texts": {
"Permission:WeChat.Official": "Official",
"Permission:WeChat.MiniProgram": "Mini Program"
"Permission:WeChat.MiniProgram": "Mini Program",
"Permission:WeChat.Work": "Work"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"culture": "zh-Hans",
"texts": {
"Permission:WeChat.Official": "公众平台",
"Permission:WeChat.MiniProgram": "小程序"
"Permission:WeChat.MiniProgram": "小程序",
"Permission:WeChat.Work": "企业微信"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using LINGYUN.Abp.WeChat.MiniProgram.Settings;
using LINGYUN.Abp.WeChat.Official.Settings;
using LINGYUN.Abp.WeChat.Settings;
using LINGYUN.Abp.WeChat.Work.Settings;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Authorization.Permissions;
Expand Down Expand Up @@ -127,6 +128,32 @@ protected async virtual Task<SettingGroupResult> GetAllForProviderAsync(string p

settingGroups.AddGroup(wechatSettingGroup);

if (await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.Work))
{
#region 企业微信
var wechatWorkSettingGroup = new SettingGroupDto(L["DisplayName:WeChatWork"], L["Description:WeChatWork"]);

var workLoginSetting = wechatWorkSettingGroup.AddSetting(L["UserLogin"], L["UserLogin"]);
workLoginSetting.AddDetail(
SettingDefinitionManager.Get(WeChatWorkSettingNames.EnabledQuickLogin),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(WeChatWorkSettingNames.EnabledQuickLogin, providerName, providerKey),
ValueType.Boolean,
providerName);

var workConnectionSetting = wechatWorkSettingGroup.AddSetting(L["DisplayName:Connection"], L["Description:Connection"]);

workConnectionSetting.AddDetail(
SettingDefinitionManager.Get(WeChatWorkSettingNames.Connection.CorpId),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(WeChatWorkSettingNames.Connection.CorpId, providerName, providerKey),
ValueType.String,
providerName);

settingGroups.AddGroup(wechatWorkSettingGroup);
#endregion
}

return settingGroups;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using LINGYUN.Abp.WeChat.Localization;
using LINGYUN.Abp.WeChat.MiniProgram.Features;
using LINGYUN.Abp.WeChat.Official.Features;
using LINGYUN.Abp.WeChat.Work.Features;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Features;
using Volo.Abp.Localization;

namespace LINGYUN.Abp.WeChat.SettingManagement
Expand All @@ -13,10 +17,16 @@ public override void Define(IPermissionDefinitionContext context)
L("Permission:WeChat"));

wechatGroup.AddPermission(
WeChatSettingPermissionNames.Official, L("Permission:WeChat.Official"));
WeChatSettingPermissionNames.Official, L("Permission:WeChat.Official"))
.RequireFeatures(WeChatOfficialFeatures.Enable);

wechatGroup.AddPermission(
WeChatSettingPermissionNames.MiniProgram, L("Permission:WeChat.MiniProgram"));
WeChatSettingPermissionNames.MiniProgram, L("Permission:WeChat.MiniProgram"))
.RequireFeatures(WeChatMiniProgramFeatures.Enable);

wechatGroup.AddPermission(
WeChatSettingPermissionNames.Work, L("Permission:WeChat.Work"))
.RequireFeatures(WeChatWorkFeatureNames.Enable);
}

protected LocalizableString L(string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class WeChatSettingPermissionNames

public const string Official = GroupName + ".Official";
public const string MiniProgram = GroupName + ".MiniProgram";
public const string Work = GroupName + ".Work";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"Features:AppChatMessage.LimitDesc": "设置以限制企业微信群聊消息推送上限.",
"Features:AppChatMessage.LimitInterval": "企业微信群聊消息限制周期",
"Features:AppChatMessage.LimitIntervalDesc": "设置企业微信群聊消息限制周期(时间刻度: 分).每企业所有应用发送群消息不可超过2万人次/分,不可超过30万人次/小时.",
"DisplayName:WeChatWork": "企业微信",
"Description:WeChatWork": "企业微信应用集成",
"DisplayName:Connection": "连接参数",
"Description:Connection": "企业微信连接参数",
"DisplayName:WeChatWork.Connection.CorpId": "Corp Id",
"Description:WeChatWork.Connection.CorpId": "Each enterprise has a unique corpid, to obtain this information, you can view \"Enterprise ID\" under \"My Enterprise\" - \"Enterprise Information\" in the management background (requires administrator permissions).",
"DisplayName:WeChatWork.EnabledQuickLogin": "Enabled Quick Login",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"Features:AppChatMessage.LimitDesc": "设置以限制企业微信群聊消息推送上限.",
"Features:AppChatMessage.LimitInterval": "企业微信群聊消息限制周期",
"Features:AppChatMessage.LimitIntervalDesc": "设置企业微信群聊消息限制周期(时间刻度: 分).每企业所有应用发送群消息不可超过2万人次/分,不可超过30万人次/小时.",
"DisplayName:WeChatWork": "企业微信",
"Description:WeChatWork": "企业微信应用集成",
"DisplayName:Connection": "连接参数",
"Description:Connection": "企业微信连接参数",
"DisplayName:WeChatWork.Connection.CorpId": "企业Id",
"Description:WeChatWork.Connection.CorpId": "每个企业都拥有唯一的corpid,获取此信息可在管理后台“我的企业”-“企业信息”下查看“企业ID”(需要有管理员权限)",
"DisplayName:WeChatWork.EnabledQuickLogin": "启用快捷登录",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected virtual SettingDefinition[] GetConnectionSettings()
WeChatWorkSettingNames.Connection.CorpId,
displayName: L("DisplayName:WeChatWork.Connection.CorpId"),
description: L("Description:WeChatWork.Connection.CorpId"),
isEncrypted: false)
isEncrypted: true)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class NotificationPublishJobArgs
public long NotificationId { get; set; }
public string ProviderType { get; set; }
public List<UserIdentifier> UserIdentifiers { get; set; }
public NotificationPublishJobArgs()
{
UserIdentifiers = new List<UserIdentifier>();
}
public NotificationPublishJobArgs(long id, string providerType, List<UserIdentifier> userIdentifiers, Guid? tenantId = null)
{
NotificationId = id;
Expand Down

0 comments on commit 574802e

Please sign in to comment.