generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created flows module and defined a flow until getting an access token #…
- Loading branch information
raghunandanarava
committed
Jun 7, 2022
1 parent
28ffc6a
commit 3665696
Showing
13 changed files
with
85 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Controller } from '@nestjs/common'; | ||
|
||
@Controller('flows') | ||
export class FlowsController {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { FlowsController } from './flows.controller'; | ||
import { FlowsService } from './flows.service'; | ||
import { TokenModule } from '../token/token.module'; | ||
|
||
@Module({ | ||
imports: [TokenModule], | ||
controllers: [FlowsController], | ||
providers: [FlowsService], | ||
exports: [FlowsService], | ||
}) | ||
export class FlowsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { FlowsService } from './flows.service'; | ||
|
||
describe('FlowsService', () => { | ||
let service: FlowsService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [FlowsService], | ||
}).compile(); | ||
|
||
service = module.get<FlowsService>(FlowsService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Injectable, Inject } from '@nestjs/common'; | ||
import { TokenService } from '../token/token.service'; | ||
|
||
@Injectable() | ||
export class FlowsService { | ||
@Inject(TokenService) | ||
private readonly tokenService: TokenService; | ||
|
||
async clientCredentialsFlow(issuer_s: string) { | ||
const accessToken = await this.tokenService.requestToken(issuer_s); | ||
return accessToken; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { LoginUserDto } from './Dto/LoginUser.dto'; | ||
import { FlowsService } from '../flows/flows.service'; | ||
|
||
@Injectable() | ||
export class UserService { | ||
login(loginUserDto: LoginUserDto): { result: string } { | ||
return { result:'Login Successful' }; | ||
@Inject(FlowsService) | ||
private readonly flowsService: FlowsService; | ||
|
||
async login(loginUserDto: LoginUserDto): Promise<any> { | ||
return await this.flowsService.clientCredentialsFlow( | ||
process.env.ISSUER_STRING, | ||
); | ||
} | ||
} |