mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -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.
|
/// The user password (hashed, it can't be read like that). The hashing format is implementation defined.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeIgnore]
|
[SerializeIgnore]
|
||||||
public string Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public bool HasPassword => Password != null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of permissions of the user. The format of this is implementation dependent.
|
/// The list of permissions of the user. The format of this is implementation dependent.
|
||||||
|
@ -28,7 +28,7 @@ public class PasswordResetRequest
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The old password
|
/// The old password
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OldPassword { get; set; }
|
public string? OldPassword { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The new password
|
/// The new password
|
||||||
|
@ -316,7 +316,7 @@ namespace Kyoo.Authentication.Views
|
|||||||
public async Task<ActionResult<User>> ResetPassword([FromBody] PasswordResetRequest request)
|
public async Task<ActionResult<User>> ResetPassword([FromBody] PasswordResetRequest request)
|
||||||
{
|
{
|
||||||
User user = await users.Get(User.GetIdOrThrow());
|
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 Forbid(new RequestError("The old password is invalid."));
|
||||||
return await users.Patch(
|
return await users.Patch(
|
||||||
user.Id,
|
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");
|
.HasColumnName("external_id");
|
||||||
|
|
||||||
b.Property<string>("Password")
|
b.Property<string>("Password")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasColumnName("password");
|
.HasColumnName("password");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user