Skip to content

Commit

Permalink
Merge pull request #2209 from tidusjar/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tidusjar authored Apr 28, 2018
2 parents 8e3ae37 + 675ed52 commit 4ed18e8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 61 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v3.0.3239 (2018-04-26)

### **Fixes**

- Potential fix for #2119. [Jamie Rees]

- Use the Application URL if we have it to fix #2201. [Jamie]


## v3.0.3239 (2018-04-26)

### **New Features**
Expand Down
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#tool "nuget:?package=GitVersion.CommandLine"
#addin "Cake.Gulp"
#addin "Cake.Npm"
#addin "nuget:?package=Cake.Npm&version=0.13.0"
#addin "SharpZipLib"
#addin nuget:?package=Cake.Compression&version=0.1.4
#addin "Cake.Incubator"
Expand Down
17 changes: 2 additions & 15 deletions src/Ombi.Core/Authentication/PlexOAuthManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,8 @@ public async Task<PlexAccount> GetAccount(string accessToken)

public async Task<Uri> GetOAuthUrl(int pinId, string code, string websiteAddress = null)
{
Uri url;
if (websiteAddress.IsNullOrEmpty())
{
var settings = await _customizationSettingsService.GetSettingsAsync();
if (settings.ApplicationUrl.IsNullOrEmpty())
{
return null;
}

url = _api.GetOAuthUrl(pinId, code, settings.ApplicationUrl, false);
}
else
{
url = _api.GetOAuthUrl(pinId, code, websiteAddress, false);
}
var settings = await _customizationSettingsService.GetSettingsAsync();
var url = _api.GetOAuthUrl(pinId, code, settings.ApplicationUrl.IsNullOrEmpty() ? websiteAddress : settings.ApplicationUrl, false);

return url;
}
Expand Down
22 changes: 2 additions & 20 deletions src/Ombi/ClientApp/app/wizard/createadmin/createadmin.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Component } from "@angular/core";
import { Router } from "@angular/router";

import { AuthService } from "../../auth/auth.service";
import { IdentityService } from "../../services";
import { NotificationService } from "../../services";
import { SettingsService } from "../../services";

@Component({
templateUrl: "./createadmin.component.html",
Expand All @@ -15,28 +13,12 @@ export class CreateAdminComponent {
public password: string;

constructor(private identityService: IdentityService, private notificationService: NotificationService,
private router: Router, private auth: AuthService, private settings: SettingsService) { }
private router: Router) { }

public createUser() {
this.identityService.createWizardUser({username: this.username, password: this.password, usePlexAdminAccount: false}).subscribe(x => {
if (x) {
// Log me in.
this.auth.login({ username: this.username, password: this.password, rememberMe: false, usePlexOAuth:false }).subscribe(c => {

localStorage.setItem("id_token", c.access_token);

// Mark that we have done the settings now
this.settings.getOmbi().subscribe(ombi => {
ombi.wizard = true;

this.settings.saveOmbi(ombi).subscribe(x => {

this.router.navigate(["search"]);
});

});

});
this.router.navigate(["login"]);
} else {
this.notificationService.error("There was an error... You might want to put this on Github...");
}
Expand Down
27 changes: 3 additions & 24 deletions src/Ombi/ClientApp/app/wizard/plex/plex.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { Router } from "@angular/router";

import { PlexService } from "../../services";
import { IdentityService, NotificationService, SettingsService } from "../../services";
import { AuthService } from "./../../auth/auth.service";
import { IdentityService, NotificationService } from "../../services";

@Component({
templateUrl: "./plex.component.html",
Expand All @@ -15,9 +14,7 @@ export class PlexComponent {

constructor(private plexService: PlexService, private router: Router,
private notificationService: NotificationService,
private identityService: IdentityService,
private settings: SettingsService,
private auth: AuthService) { }
private identityService: IdentityService) { }

public requestAuthToken() {
this.plexService.logIn(this.login, this.password).subscribe(x => {
Expand All @@ -32,25 +29,7 @@ export class PlexComponent {
usePlexAdminAccount: true,
}).subscribe(y => {
if (y) {
this.auth.login({ username: this.login, password: this.password, rememberMe: false, usePlexOAuth: false }).subscribe(c => {
localStorage.setItem("id_token", c.access_token);

// Mark that we have done the settings now
this.settings.getOmbi().subscribe(ombi => {
ombi.wizard = true;

this.settings.saveOmbi(ombi).subscribe(s => {
this.settings.getUserManagementSettings().subscribe(usr => {

usr.importPlexAdmin = true;
this.settings.saveUserManagementSettings(usr).subscribe(saved => {
this.router.navigate(["login"]);
});
});

});
});
});
this.router.navigate(["login"]);
} else {
this.notificationService.error("Could not get the Plex Admin Information");
return;
Expand Down
11 changes: 10 additions & 1 deletion src/Ombi/Controllers/IdentityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class IdentityController : Controller
public IdentityController(OmbiUserManager user, IMapper mapper, RoleManager<IdentityRole> rm, IEmailProvider prov,
ISettingsService<EmailNotificationSettings> s,
ISettingsService<CustomizationSettings> c,
ISettingsService<OmbiSettings> ombiSettings,
IWelcomeEmail welcome,
IMovieRequestRepository m,
ITvRequestRepository t,
Expand All @@ -73,6 +74,7 @@ public IdentityController(OmbiUserManager user, IMapper mapper, RoleManager<Iden
_issuesRepository = issues;
_requestLogRepository = requestLog;
_issueCommentsRepository = issueComments;
OmbiSettings = ombiSettings;
}

private OmbiUserManager UserManager { get; }
Expand All @@ -81,6 +83,7 @@ public IdentityController(OmbiUserManager user, IMapper mapper, RoleManager<Iden
private IEmailProvider EmailProvider { get; }
private ISettingsService<EmailNotificationSettings> EmailSettings { get; }
private ISettingsService<CustomizationSettings> CustomizationSettings { get; }
private ISettingsService<OmbiSettings> OmbiSettings { get; }
private IWelcomeEmail WelcomeEmail { get; }
private IMovieRequestRepository MovieRepo { get; }
private ITvRequestRepository TvRepo { get; }
Expand All @@ -107,7 +110,7 @@ public IdentityController(OmbiUserManager user, IMapper mapper, RoleManager<Iden
public async Task<bool> CreateWizardUser([FromBody] CreateUserWizardModel user)
{
var users = UserManager.Users;
if (users.Any())
if (users.Any(x => !x.UserName.Equals("api", StringComparison.CurrentCultureIgnoreCase)))
{
// No one should be calling this. Only the wizard
return false;
Expand Down Expand Up @@ -174,6 +177,12 @@ private async Task<bool> SaveWizardUser(CreateUserWizardModel user, OmbiUser use
{
LogErrors(result);
}

// Update the wizard flag
var settings = await OmbiSettings.GetSettingsAsync();
settings.Wizard = true;
await OmbiSettings.SaveSettingsAsync(settings);

return result.Succeeded;
}

Expand Down

0 comments on commit 4ed18e8

Please sign in to comment.