Added the ability to use a cookie to login. Mainly for Org

pull/1614/head
tidusjar 7 years ago
parent d6b3c7ac2c
commit 759b8a3e31

@ -1,6 +1,9 @@
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({
@ -9,14 +12,24 @@ export function authHttpServiceFactory(http: Http, options: RequestOptions) {
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 { }

@ -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"]);
}
}
}

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

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

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

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

Loading…
Cancel
Save