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

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

@ -1,22 +1,35 @@
import { NgModule } from "@angular/core"; import { NgModule } from "@angular/core";
import { Http, RequestOptions } from "@angular/http"; import { Http, RequestOptions } from "@angular/http";
import { RouterModule, Routes } from "@angular/router";
import { AuthConfig, AuthHttp } from "angular2-jwt"; import { AuthConfig, AuthHttp } from "angular2-jwt";
import { CookieService } from "ng2-cookies";
import { CookieComponent } from "./cookie.component";
export function authHttpServiceFactory(http: Http, options: RequestOptions) { export function authHttpServiceFactory(http: Http, options: RequestOptions) {
return new AuthHttp(new AuthConfig({ return new AuthHttp(new AuthConfig({
tokenName: "id_token", tokenName: "id_token",
tokenGetter: (() => localStorage.getItem("id_token")!), tokenGetter: (() => localStorage.getItem("id_token")!),
globalHeaders: [{ "Content-Type": "application/json" }], globalHeaders: [{ "Content-Type": "application/json" }],
}), http, options); }), http, options);
} }
const routes: Routes = [
{ path: "auth/cookie", component: CookieComponent },
];
@NgModule({ @NgModule({
imports : [
RouterModule.forChild(routes),
],
declarations:[
CookieComponent,
],
providers: [ providers: [
{ {
provide: AuthHttp, provide: AuthHttp,
useFactory: authHttpServiceFactory, useFactory: authHttpServiceFactory,
deps: [Http, RequestOptions], deps: [Http, RequestOptions],
}, },
CookieService,
], ],
}) })
export class AuthModule {} 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", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" "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": { "ng2-dragula": {
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/ng2-dragula/-/ng2-dragula-1.5.0.tgz", "resolved": "https://registry.npmjs.org/ng2-dragula/-/ng2-dragula-1.5.0.tgz",

@ -46,6 +46,7 @@
"html-loader": "0.5.1", "html-loader": "0.5.1",
"intro.js-mit": "^3.0.0", "intro.js-mit": "^3.0.0",
"jquery": "3.2.1", "jquery": "3.2.1",
"ng2-cookies": "^1.0.12",
"ng2-dragula": "1.5.0", "ng2-dragula": "1.5.0",
"ngx-clipboard": "^8.0.4", "ngx-clipboard": "^8.0.4",
"ngx-infinite-scroll": "^0.5.1", "ngx-infinite-scroll": "^0.5.1",

@ -52,6 +52,7 @@ module.exports = function (env) {
'ngx-clipboard', 'ngx-clipboard',
'bootswatch/superhero/bootstrap.min.css', 'bootswatch/superhero/bootstrap.min.css',
'style-loader', 'style-loader',
'ng2-cookies',
//'ng2-dragula', //'ng2-dragula',
//'dragula/dist/dragula.min.css' //'dragula/dist/dragula.min.css'
] ]

Loading…
Cancel
Save