mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Added the ability to use a cookie to login. Mainly for Org
This commit is contained in:
parent
d6b3c7ac2c
commit
759b8a3e31
7 changed files with 47 additions and 12 deletions
|
@ -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 { }
|
||||
|
|
0
src/Ombi/ClientApp/app/auth/cookie.component.html
Normal file
0
src/Ombi/ClientApp/app/auth/cookie.component.html
Normal file
23
src/Ombi/ClientApp/app/auth/cookie.component.ts
Normal file
23
src/Ombi/ClientApp/app/auth/cookie.component.ts
Normal file
|
@ -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
|
5
src/Ombi/package-lock.json
generated
5
src/Ombi/package-lock.json
generated
|
@ -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…
Add table
Add a link
Reference in a new issue