Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/learning-token-backend/src/config/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ export const typeOrmAsyncConfig: TypeOrmModuleAsyncOptions = {
entities: [__dirname + '/../**/*.entity.{js,ts}'],
migrations: [__dirname + '/../database/migrations/*{.ts,.js}'],

extra: {
charset: 'utf8mb4_unicode_ci'
},
synchronize: true
// logging: true
}
Expand Down
29 changes: 4 additions & 25 deletions src/learning-token-backend/src/modules/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,7 @@ export class AuthController {
const result = await this.service.adminLogin(loginRequestDto)
if (result) {
return {
status: HttpStatus.CREATED,
message: 'User has logged in successfully',
result: result
}
} else {
throw new NotFoundException('Invalid Credentials')
}
} catch (error) {
throw new NotFoundException('Invalid Credentials')
}
}

@Post('institution-login')
private async institution_login(
@Body() loginRequestDto: InstitutionLoginRequestDto
) {
try {
loginRequestDto.type = 'Institution'
const result = await this.service.login(loginRequestDto)
if (result) {
return {
status: HttpStatus.CREATED, // TODO: should be 200
status: HttpStatus.OK,
message: 'User has logged in successfully',
result: result
}
Expand Down Expand Up @@ -108,7 +87,7 @@ export class AuthController {
const result = await this.service.login(loginRequestDto)
if (result) {
return {
status: HttpStatus.CREATED,
status: HttpStatus.OK,
message: 'User has logged in successfully',
result: result
}
Expand Down Expand Up @@ -146,7 +125,7 @@ export class AuthController {
const result = await this.service.login(loginRequestDto)
if (result) {
return {
status: HttpStatus.CREATED,
status: HttpStatus.OK,
message: 'User has logged in successfully',
result: result
}
Expand Down Expand Up @@ -182,7 +161,7 @@ export class AuthController {
@Get('refresh-access-token')
refreshAccessToken(@Request() req) {
return {
status: HttpStatus.CREATED,
status: HttpStatus.OK,
message: 'Access token generated',
result: this.service.refreshToken(req.user)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class AuthService {
@InjectRepository(Learner)
private readonly learnerRepository: Repository<Learner>,
@InjectRepository(Instructor)
private readonly insturctorRepository: Repository<Instructor>,
private readonly instructorRepository: Repository<Instructor>,
@Inject(JwtService)
private readonly jwtService: JwtService,
@InjectRepository(Role)
Expand Down Expand Up @@ -109,7 +109,7 @@ export class AuthService {
user.email = email
// user.publicAddress = publicAddress
user.password = this.jwtService.encodePassword(password)
const registeredUser = await this.insturctorRepository.save(user)
const registeredUser = await this.instructorRepository.save(user)
return {
id: registeredUser.id,
name: registeredUser.name,
Expand Down Expand Up @@ -162,7 +162,7 @@ export class AuthService {
let user = null
if (loginRequestDto.type == 'Instructor') {
//find instructor
user = await this.insturctorRepository.findOne({
user = await this.instructorRepository.findOne({
where: { email: loginRequestDto.email },
relations: ['role']
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export class JwtService {
public async verify(token: string): Promise<any> {
try {
return this.jwt.verify(token)
} catch (err) {}
} catch (err) {
return null
}
}
}
2 changes: 1 addition & 1 deletion src/learning-token-backend/src/utils/kaledio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as dotenv from 'dotenv'
dotenv.config()
const kaledio =
process.env.KALEIDO_HD_WALLET_RPC_URL +
'api/v1/wallets/:walletId/accounts/:accountIndex'
'/api/v1/wallets/:walletId/accounts/:accountIndex'
// ;('https://u0k1dk029t:hU5ERoJz_xLvmQzr8h1jmLr6a3Afn4Oa6T4NHjKJ2ro@u0jtyl6s8p-u0gt6e2xu2-hdwallet.us0-aws.kaleido.io/api/v1/wallets/:walletId/accounts/:accountIndex')
export const getWallet = async (type: string, id: number) => {
//decrement id by 1 since the index starts from 0
Expand Down