mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Make password optional
This commit is contained in:
parent
3bb36f5e78
commit
115d52977d
@ -54,7 +54,9 @@ namespace Kyoo.Abstractions.Models
|
||||
/// The user password (hashed, it can't be read like that). The hashing format is implementation defined.
|
||||
/// </summary>
|
||||
[SerializeIgnore]
|
||||
public string Password { get; set; }
|
||||
public string? Password { get; set; }
|
||||
|
||||
public bool HasPassword => Password != null;
|
||||
|
||||
/// <summary>
|
||||
/// The list of permissions of the user. The format of this is implementation dependent.
|
||||
|
@ -28,7 +28,7 @@ public class PasswordResetRequest
|
||||
/// <summary>
|
||||
/// The old password
|
||||
/// </summary>
|
||||
public string OldPassword { get; set; }
|
||||
public string? OldPassword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The new password
|
||||
|
@ -316,7 +316,7 @@ namespace Kyoo.Authentication.Views
|
||||
public async Task<ActionResult<User>> ResetPassword([FromBody] PasswordResetRequest request)
|
||||
{
|
||||
User user = await users.Get(User.GetIdOrThrow());
|
||||
if (!BCryptNet.Verify(request.OldPassword, user.Password))
|
||||
if (user.HasPassword && !BCryptNet.Verify(request.OldPassword, user.Password))
|
||||
return Forbid(new RequestError("The old password is invalid."));
|
||||
return await users.Patch(
|
||||
user.Id,
|
||||
|
1313
back/src/Kyoo.Postgresql/Migrations/20240302151906_MakePasswordOptional.Designer.cs
generated
Normal file
1313
back/src/Kyoo.Postgresql/Migrations/20240302151906_MakePasswordOptional.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Kyoo.Postgresql.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MakePasswordOptional : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "password",
|
||||
table: "users",
|
||||
type: "text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "text"
|
||||
);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "password",
|
||||
table: "users",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "",
|
||||
oldClrType: typeof(string),
|
||||
oldType: "text",
|
||||
oldNullable: true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -620,7 +620,6 @@ namespace Kyoo.Postgresql.Migrations
|
||||
.HasColumnName("external_id");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("password");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user