diff --git a/src/Ombi/ClientApp/app/auth/auth.module.ts b/src/Ombi/ClientApp/app/auth/auth.module.ts index 2c58b2f99..49f22a98f 100644 --- a/src/Ombi/ClientApp/app/auth/auth.module.ts +++ b/src/Ombi/ClientApp/app/auth/auth.module.ts @@ -1,22 +1,35 @@ import { NgModule } from "@angular/core"; import { Http, RequestOptions } from "@angular/http"; +import { RouterModule, Routes } from "@angular/router"; import { AuthConfig, AuthHttp } from "angular2-jwt"; +import { CookieService } from "ng2-cookies"; +import { CookieComponent } from "./cookie.component"; export function authHttpServiceFactory(http: Http, options: RequestOptions) { return new AuthHttp(new AuthConfig({ - tokenName: "id_token", - tokenGetter: (() => localStorage.getItem("id_token")!), - globalHeaders: [{ "Content-Type": "application/json" }], + tokenName: "id_token", + tokenGetter: (() => localStorage.getItem("id_token")!), + globalHeaders: [{ "Content-Type": "application/json" }], }), http, options); } +const routes: Routes = [ + { path: "auth/cookie", component: CookieComponent }, +]; @NgModule({ + imports : [ + RouterModule.forChild(routes), + ], + declarations:[ + CookieComponent, + ], providers: [ { provide: AuthHttp, useFactory: authHttpServiceFactory, deps: [Http, RequestOptions], }, + CookieService, ], }) -export class AuthModule {} +export class AuthModule { } diff --git a/src/Ombi/ClientApp/app/auth/cookie.component.html b/src/Ombi/ClientApp/app/auth/cookie.component.html new file mode 100644 index 000000000..e69de29bb diff --git a/src/Ombi/ClientApp/app/auth/cookie.component.ts b/src/Ombi/ClientApp/app/auth/cookie.component.ts new file mode 100644 index 000000000..c4c6dcb67 --- /dev/null +++ b/src/Ombi/ClientApp/app/auth/cookie.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from "@angular/core"; +import { CookieService } from "ng2-cookies"; +import { Router } from "@angular/router"; + +@Component({ + templateUrl: "cookie.component.html", +}) +export class CookieComponent implements OnInit { + constructor(private readonly cookieService: CookieService, + private readonly router: Router) { } + + public ngOnInit() { + debugger; + const cookie = this.cookieService.getAll(); + if(cookie.Auth) { + const jwtVal = cookie.Auth; + localStorage.setItem("id_token", jwtVal); + this.router.navigate(["search"]); + } else { + this.router.navigate(["login"]); + } + } +} diff --git a/src/Ombi/Dockerfile b/src/Ombi/Dockerfile deleted file mode 100644 index ea0c4ab92..000000000 --- a/src/Ombi/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM microsoft/dotnet:1.1-sdk-msbuild -ARG source=./bin/Release/netcoreapp1.1/publish -WORKDIR /app -COPY $source . -ENV ASPNETCORE_URLS http://*:5000 -EXPOSE 5000 -ENTRYPOINT ["dotnet", "Ombi.dll"] -COPY . /app \ No newline at end of file diff --git a/src/Ombi/package-lock.json b/src/Ombi/package-lock.json index 62dcd0404..e1307e579 100644 --- a/src/Ombi/package-lock.json +++ b/src/Ombi/package-lock.json @@ -4781,6 +4781,11 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" }, + "ng2-cookies": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/ng2-cookies/-/ng2-cookies-1.0.12.tgz", + "integrity": "sha1-Pz5hPgE3sGSbcFxngHS0vQgUnMw=" + }, "ng2-dragula": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/ng2-dragula/-/ng2-dragula-1.5.0.tgz", diff --git a/src/Ombi/package.json b/src/Ombi/package.json index f0a3defa8..b09fb3fe5 100644 --- a/src/Ombi/package.json +++ b/src/Ombi/package.json @@ -46,6 +46,7 @@ "html-loader": "0.5.1", "intro.js-mit": "^3.0.0", "jquery": "3.2.1", + "ng2-cookies": "^1.0.12", "ng2-dragula": "1.5.0", "ngx-clipboard": "^8.0.4", "ngx-infinite-scroll": "^0.5.1", diff --git a/src/Ombi/webpack.config.vendor.js b/src/Ombi/webpack.config.vendor.js index a90c24491..168aff6fc 100644 --- a/src/Ombi/webpack.config.vendor.js +++ b/src/Ombi/webpack.config.vendor.js @@ -52,6 +52,7 @@ module.exports = function (env) { 'ngx-clipboard', 'bootswatch/superhero/bootstrap.min.css', 'style-loader', + 'ng2-cookies', //'ng2-dragula', //'dragula/dist/dragula.min.css' ]