This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (await _viewModel.UserViewModel.RestorePermitAsync()) | |
{ | |
// Navigate to the home page | |
// if a valid JWT not found! | |
await GoHomeAsync(); | |
} | |
else | |
{ | |
// Either register or login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Shell> | |
<ShellItem Route="Bootstrap"> | |
<ShellContent ContentTemplate="{DataTemplate local:BootPage}" /> | |
</ShellItem> | |
<ShellItem Route="Onboarding"> | |
<ShellContent ContentTemplate="{DataTemplate local:OnboardingPage}" /> | |
</ShellItem> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (result.HttpStatus == System.Net.HttpStatusCode.Unauthorized) | |
{ | |
/* | |
* The token has expired. Renew is auto-renew option | |
* has been requested. | |
*/ | |
if (Permit != null && AutoTokenRenew) | |
{ | |
if (ex.Call.Response.Headers.Contains("Token-Expired")) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JwtExtension | |
{ | |
public static void AddJwt(this IServiceCollection services, IConfiguration configuration) | |
{ | |
services.Configure<JwtSettings>(options => configuration.GetSection("JwtSettings").Bind(options)); | |
JwtSettings jwtSettings = configuration.GetSection(nameof(JwtSettings)).Get<JwtSettings>(); | |
services.AddAuthentication(options => | |
{ | |
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IdentityExtension | |
{ | |
public static void AddIdentity(this IServiceCollection services, IConfiguration configuration) | |
{ | |
services.Configure<IdentitySettings>(options => configuration.GetSection("IdentitySettings").Bind(options)); | |
IdentitySettings identitySettings = configuration.GetSection(nameof(IdentitySettings)).Get<IdentitySettings>(); | |
services.AddMvc(options => { | |
var policy = new AuthorizationPolicyBuilder() | |
.RequireAuthenticatedUser() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method gets called by the runtime. Use this method to add services to the container. | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddNester(); | |
services.AddDbContext<JwtauthContext>(options => | |
options.UseSqlite("Data Source=/var/app/source/shared/Jwtauth.db")); | |
services.AddScoped<IIndustryRepository, IndustryRepository>(); | |
// Set API Version | |
services.AddApiVersioning(options => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Result | |
{ | |
Succeeded = 0, | |
Failed = -1, | |
Unauthorized = -5, | |
InternalError = -10, | |
UserNotFound = -15, | |
IncorrectEmail = -20, | |
EmailNotConfirmed = -25, | |
IncorrectSecurityCode = -30, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JwtKey"])); | |
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); | |
var expires = DateTime.Now.AddHours(Convert.ToDouble(_configuration["JwtExpireHours"])); | |
var token = new JwtSecurityToken( | |
_configuration["JwtIssuer"], | |
_configuration["JwtIssuer"], | |
claims, | |
expires: expires, | |
signingCredentials: creds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<ResultMultiple<Share>> QuerySharesAsync( | |
bool doCache = true, bool throwIfError = true) | |
{ | |
Share shareSeed = new Share(); | |
shareSeed.OwnedBy = _selectedIndustry; | |
ResultMultiple<Share> result = await ResultMultipleUI<Share>.WaitForObjectAsync( | |
backend, throwIfError, shareSeed, doCache); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string clientSignature = JsonConvert.SerializeObject(( | |
Model: DeviceInfo.Model, | |
Manufacturer: DeviceInfo.Manufacturer, | |
Name: DeviceInfo.Name, | |
Platform: DeviceInfo.Platform, | |
Idiom: DeviceInfo.Idiom, | |
DeviceType: DeviceInfo.DeviceType, | |
HardwareVersion: DeviceInfo.VersionString, | |
SoftwareVersion: typeof(MainPage).GetTypeInfo() |
NewerOlder