WXWork7.Account 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package WXWork7.Account --version 1.0.2
                    
NuGet\Install-Package WXWork7.Account -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WXWork7.Account" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WXWork7.Account" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="WXWork7.Account" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WXWork7.Account --version 1.0.2
                    
#r "nuget: WXWork7.Account, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WXWork7.Account@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WXWork7.Account&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=WXWork7.Account&version=1.0.2
                    
Install as a Cake Tool

WXWork7 & WXWork7.Account

一、WXWork7

基于.Net7的企业微信Api

  1. Program.cs
builder.Services.AddHttpClient();
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddMemoryCache();
builder.Services.AddWXWork();
  1. appsettings.json
  "WXWork": 
    {
      "AgentId": 应用Id,
      "CorpId": "企业Id",
      "Secret": "企业密钥"
    }
  

3.使用示例

 public async Task OnGetAsync([FromServices] WXWork q)
 {
     await q.SendTextMessageAsync( "ZhangSan", "1432");
 }

二、WXWork7.Account

添加了企业微信OAuth授权登录逻辑和简单的用户、角色管理模块

  1. Program.cs
    builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(option =>
    {
        option.LoginPath = new PathString("/account/login");
        option.AccessDeniedPath = new PathString("/account/denied");
    });
    builder.Services.AddAuthorization(options =>
    {
        //options.AddPolicy(ERole.Admin.ToString(), policy => policy.RequireRole(ERole.Admin.ToString(), ERole.SystemAdmin.ToString()));
        //options.AddPolicy(ERole.SystemAdmin.ToString(), policy => policy.RequireRole(ERole.SystemAdmin.ToString()));
        //options.AddPolicy(ERole.Report.ToString(), policy => policy.RequireRole(ERole.Report.ToString(), ERole.Admin.ToString(), ERole.SystemAdmin.ToString()));
    });

    builder.Services.AddWXWorkWithAccount(connectionString);


    ...

    app.UseAuthentication();
    app.UseAuthorization();


  1. appsettings.json
  "WXWork": 
    {
      "AgentId": 应用Id,
      "CorpId": "企业Id",
      "Secret": "企业密钥"
    },
  "WXWork.Account": {
    "Roles": [ "角色A", "角色B", "角色C" ],
    "Ext": "用户扩展属性的文字说明"
  }  

3._Layout.cshtml


    <li class="nav-item">
        <a class="nav-link text-dark" asp-area="" asp-page="/User/Index">用户</a>
    </li>

另外,还改造了Demo的_Layout.cshtml、_LoginPartial.cshtml、Error.cshtml等页面。

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.9 229 12/20/2023
1.0.8 193 12/18/2023
1.0.7 212 12/10/2023
1.0.6 193 12/6/2023
1.0.5 213 12/4/2023
1.0.4 187 12/4/2023
1.0.3 176 12/4/2023
1.0.2 189 12/1/2023