diff --git a/back/src/Kyoo.Authentication/Views/AuthApi.cs b/back/src/Kyoo.Authentication/Views/AuthApi.cs
index 7da38e8e..754c9384 100644
--- a/back/src/Kyoo.Authentication/Views/AuthApi.cs
+++ b/back/src/Kyoo.Authentication/Views/AuthApi.cs
@@ -19,9 +19,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Net.Http;
-using System.Net.Http.Json;
-using System.Text;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
@@ -186,6 +183,23 @@ namespace Kyoo.Authentication.Views
);
}
+ ///
+ /// Unlink account
+ ///
+ ///
+ /// Unlink your account from an external account.
+ ///
+ /// The provider code.
+ /// Your updated user account
+ [HttpDelete("login/{provider}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [UserOnly]
+ public Task UnlinkAccount(string provider)
+ {
+ Guid id = User.GetIdOrThrow();
+ return users.DeleteExternalToken(id, provider);
+ }
+
///
/// Login.
///
@@ -257,7 +271,6 @@ namespace Kyoo.Authentication.Views
/// A new access and refresh token.
/// The given refresh token is invalid.
[HttpGet("refresh")]
- [UserOnly]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(RequestError))]
public async Task> Refresh([FromQuery] string token)
diff --git a/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs
index 785bde85..451b6a91 100644
--- a/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs
+++ b/back/src/Kyoo.Core/Controllers/Repositories/UserRepository.cs
@@ -23,7 +23,6 @@ using System.Linq;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
-using Kyoo.Abstractions.Models.Exceptions;
using Kyoo.Abstractions.Models.Permissions;
using Kyoo.Abstractions.Models.Utils;
using Kyoo.Postgresql;
@@ -118,4 +117,12 @@ public class UserRepository(
await database.SaveChangesAsync();
return user;
}
+
+ public async Task DeleteExternalToken(Guid userId, string provider)
+ {
+ User user = await GetWithTracking(userId);
+ user.ExternalId.Remove(provider);
+ await database.SaveChangesAsync();
+ return user;
+ }
}