Skip to content

Commit

Permalink
docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid committed May 17, 2024
1 parent 462b87f commit 86e883d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
21 changes: 8 additions & 13 deletions 04-Presentation/Jinget.Blazor/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
//Microsoft.AspNetCore
global using Microsoft.AspNetCore.Components;
global using Jinget.Blazor.Attributes.Core;
global using Jinget.Blazor.Models;
global using Jinget.Blazor.Services.Contracts;
global using Jinget.Core.Utilities;
global using Microsoft.AspNetCore.Components.Authorization;
global using Microsoft.AspNetCore.Components.Rendering;
global using Microsoft.AspNetCore.Components.Web;

//System
global using Microsoft.AspNetCore.Components;
global using Microsoft.JSInterop;
global using MudBlazor;
global using System.Globalization;
global using System.Reflection;

//Jinget
global using Jinget.Core.Utilities;
global using Jinget.Blazor.Attributes.Core;
global using Jinget.Blazor.Models;

global using System.Security.Claims;
global using Jinget.Blazor.Services.Contracts;
global using Microsoft.JSInterop;
global using Microsoft.AspNetCore.Components.Authorization;
19 changes: 19 additions & 0 deletions 04-Presentation/Jinget.Blazor/Models/TokenConfigModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Jinget.Blazor.Models;

public class TokenConfigModel
{
/// <summary>
/// secret key used to generate the token
/// </summary>
public string Secret { get; set; }

/// <summary>
/// token expiration in minute. Default value is 5 minutes
/// </summary>
public int Expiration { get; set; } = 5;

/// <summary>
/// localstorage item name which holds the token. Default name is 'jinget.token'
/// </summary>
public string Name { get; set; } = "jinget.token";
}
30 changes: 29 additions & 1 deletion 04-Presentation/Jinget.Blazor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,35 @@ Blazor components optimised for RTL languaged such as Farsi, Arabic etc.
- [x] **Table**
- [x] **Dynamic Form**

## How to Use:
**Services and Providers:**
- [x] **JwtTokenService**
- [x] **LocalStorageService**
- [x] **TokenStorageService**
- [x] **TokenAuthenticationStateProvider**

## How to configure Services and Providers:

Register the services and providers like below code in your `Program.cs` file:

```
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
builder.Services.AddScoped<TokenAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(provider => provider.GetRequiredService<TokenAuthenticationStateProvider>());
new TokenConfigModel
{
Secret = <secret key used to generate the token>,
Name = <localstorage item name which holds the token. Default name is 'jinget.token'>,
Expiration = <token expiration in minute. Default value is 5 minutes>
}
builder.Services.AddScoped<IJwtTokenService>(provider => new JwtTokenService(tokenConfig.Secret, tokenConfig.Expiration));
builder.Services.AddScoped<ITokenStorageService>(provider => new TokenStorageService(provider.GetRequiredService<ILocalStorageService>(), tokenConfig.Name));
```

## How to Use Components:

Download the package from NuGet using Package Manager:
`Install-Package Jinget.Blazor`
Expand Down
4 changes: 1 addition & 3 deletions 04-Presentation/Jinget.Blazor/Services/ObjectFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using MudBlazor;

namespace Jinget.Blazor.Services;
namespace Jinget.Blazor.Services;

public class JingetObjectFactory<T>
{
Expand Down

0 comments on commit 86e883d

Please sign in to comment.