fix(user-management): 🐛 Fixed an issue where the Copy users App Link did not generate the correct app link for that user

pull/4342/head
tidusjar 3 years ago
parent 2fe41f3910
commit 8cafcdcc3b

@ -15,6 +15,7 @@
"discover",
"request-limits",
"notifications",
"settings"
"settings",
"user-management"
]
}

@ -24,6 +24,10 @@ export class IdentityService extends ServiceHelpers {
return this.http.get<string>(`${this.url}accesstoken`, {headers: this.headers});
}
public getUserAccessToken(userId: string): Observable<string> {
return this.http.get<string>(`${this.url}accesstoken/${userId}`, {headers: this.headers});
}
public getUserById(id: string): Observable<IUser> {
return this.http.get<IUser>(`${this.url}User/${id}`, {headers: this.headers});
}

@ -69,7 +69,7 @@ export class UserManagementUserComponent implements OnInit {
this.radarrService.getRootFoldersFromSettings().subscribe(x => this.radarrRootFolders = x);
this.settingsService.getCustomization().subscribe(x => this.customization = x);
this.identityService.getAccessToken().subscribe(x => this.accessToken = x);
this.identityService.getUserAccessToken(this.userId).subscribe(x => this.accessToken = x);
if(!this.edit) {
this.user = {

@ -947,6 +947,30 @@ namespace Ombi.Controllers.V1
return user.UserAccessToken;
}
[HttpGet("accesstoken/{userId}")]
[PowerUser]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<string> GetUserAccessToken(string userId)
{
var user = await UserManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
if (user == null)
{
return Guid.Empty.ToString("N");
}
if (user.UserAccessToken.IsNullOrEmpty())
{
// Let's create an access token for this user
user.UserAccessToken = Guid.NewGuid().ToString("N");
var result = await UserManager.UpdateAsync(user);
if (!result.Succeeded)
{
LogErrors(result);
return Guid.Empty.ToString("N");
}
}
return user.UserAccessToken;
}
[HttpGet("notificationpreferences")]
public async Task<List<UserNotificationPreferences>> GetUserPreferences()
{

Loading…
Cancel
Save