Merge pull request #4342 from Ombi-app/app-link

fix(user-management): 🐛 Fixed an issue where the Copy users App L…
angular-upgrade-proxy
Jamie 3 years ago committed by GitHub
commit 85815a2df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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