mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fix startup issue with jwt
This commit is contained in:
parent
673cb48b75
commit
9468346617
@ -120,11 +120,8 @@ namespace Kyoo.Authentication
|
||||
FileProvider = provider
|
||||
});
|
||||
}, SA.StaticFiles),
|
||||
SA.New<IApplicationBuilder>(app =>
|
||||
{
|
||||
app.UseAuthentication();
|
||||
}, SA.Authentication),
|
||||
SA.New<IApplicationBuilder>(app => app.UseAuthorization(), SA.Authorization)
|
||||
SA.New<IApplicationBuilder>(app => app.UseAuthentication(), SA.Authentication),
|
||||
// SA.New<IApplicationBuilder>(app => app.UseAuthorization(), SA.Authorization)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -161,14 +161,23 @@ namespace Kyoo.Authentication.Views
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get authenticated user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Get information about the currently authenticated user. This can also be used to ensure that you are
|
||||
/// logged in.
|
||||
/// </remarks>
|
||||
/// <returns>The currently authenticated user.</returns>
|
||||
/// <response code="403">The given access token is invalid.</response>
|
||||
[HttpGet("me")]
|
||||
[Authorize]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<User>> GetMe()
|
||||
{
|
||||
if (!int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier), out int userID))
|
||||
return BadRequest("Invalid access token");
|
||||
return await _users.GetById(userID);
|
||||
return Forbid();
|
||||
return await _users.Get(userID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ namespace Kyoo.Core
|
||||
/// <inheritdoc />
|
||||
public void Configure(IServiceCollection services)
|
||||
{
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddTransient<IConfigureOptions<MvcNewtonsoftJsonOptions>, JsonOptions>();
|
||||
|
||||
services.AddMvcCore()
|
||||
|
@ -161,7 +161,8 @@ namespace Kyoo.Host.Generic
|
||||
.OrderByDescending(x => x.Priority);
|
||||
|
||||
using ILifetimeScope scope = container.BeginLifetimeScope(x =>
|
||||
x.RegisterInstance(app).SingleInstance().ExternallyOwned());
|
||||
x.RegisterInstance(app).SingleInstance().ExternallyOwned()
|
||||
);
|
||||
IServiceProvider provider = scope.Resolve<IServiceProvider>();
|
||||
foreach (IStartupAction step in steps)
|
||||
step.Run(provider);
|
||||
|
Loading…
x
Reference in New Issue
Block a user