Skip to content

Commit

Permalink
fix(user-management): 🐛 Fixed an issue where the Copy users App Link …
Browse files Browse the repository at this point in the history
…did not generate the correct app link for that user
  • Loading branch information
tidusjar committed Oct 12, 2021
1 parent 2fe41f3 commit 8cafcdc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Ombi/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"discover",
"request-limits",
"notifications",
"settings"
"settings",
"user-management"
]
}
4 changes: 4 additions & 0 deletions src/Ombi/ClientApp/src/app/services/identity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
24 changes: 24 additions & 0 deletions src/Ombi/Controllers/V1/IdentityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,30 @@ public async Task<string> GetUserAccessToken()
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()
{
Expand Down

0 comments on commit 8cafcdc

Please sign in to comment.