mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix: one-click demo account
This commit is contained in:
@@ -3,9 +3,10 @@ import { faker } from '@faker-js/faker';
|
||||
import uniqid from 'uniqid';
|
||||
import AuthenticationApplication from '../Authentication/AuthApplication';
|
||||
import OrganizationService from '../Organization/OrganizationService';
|
||||
import { IAuthSignInPOJO } from '@/interfaces';
|
||||
import { OneClickDemo } from '@/system/models/OneclickDemo';
|
||||
import { SystemUser } from '@/system/models';
|
||||
import { IAuthSignInPOJO } from '@/interfaces';
|
||||
import { ICreateOneClickDemoPOJO } from './interfaces';
|
||||
|
||||
@Service()
|
||||
export class CreateOneClickDemo {
|
||||
@@ -53,8 +54,9 @@ export class CreateOneClickDemo {
|
||||
/**
|
||||
* Sign-in automicatlly using the demo id one creating an account finish.
|
||||
* @param {string} oneClickDemoId -
|
||||
* @returns {Promise<IAuthSignInPOJO>}
|
||||
*/
|
||||
async autoSignIn(oneClickDemoId: string) {
|
||||
async autoSignIn(oneClickDemoId: string): Promise<IAuthSignInPOJO> {
|
||||
const foundOneclickDemo = await OneClickDemo.query()
|
||||
.findOne('key', oneClickDemoId)
|
||||
.throwIfNotFound();
|
||||
@@ -66,14 +68,7 @@ export class CreateOneClickDemo {
|
||||
const password = '123123123';
|
||||
|
||||
const signedIn = await this.authApp.signIn(email, password);
|
||||
|
||||
|
||||
return signedIn;
|
||||
}
|
||||
}
|
||||
|
||||
interface ICreateOneClickDemoPOJO {
|
||||
email: string;
|
||||
demoId: string;
|
||||
signedIn: IAuthSignInPOJO;
|
||||
buildJob: any;
|
||||
}
|
||||
|
||||
@@ -5,21 +5,21 @@ import { CreateOneClickDemo } from './CreateOneClickDemo';
|
||||
export class OneClickDemoApplication {
|
||||
@Inject()
|
||||
private createOneClickDemoService: CreateOneClickDemo;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
* Creates one-click demo account.
|
||||
* @returns {Promise<ICreateOneClickDemoPOJO>}
|
||||
*/
|
||||
public createOneClick() {
|
||||
return this.createOneClickDemoService.createOneClickDemo();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param oneClickDemoId
|
||||
* @returns
|
||||
* Auto-sign-in to created demo account.
|
||||
* @param {string} demoId -
|
||||
* @returns {Promise<IAuthSignInPOJO>}
|
||||
*/
|
||||
public autoSignIn(oneClickDemoId: string) {
|
||||
return this.createOneClickDemoService.autoSignIn(oneClickDemoId);
|
||||
public autoSignIn(demoId: string) {
|
||||
return this.createOneClickDemoService.autoSignIn(demoId);
|
||||
}
|
||||
}
|
||||
|
||||
8
packages/server/src/services/OneClickDemo/interfaces.ts
Normal file
8
packages/server/src/services/OneClickDemo/interfaces.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { IAuthSignInPOJO } from '@/interfaces';
|
||||
|
||||
export interface ICreateOneClickDemoPOJO {
|
||||
email: string;
|
||||
demoId: string;
|
||||
signedIn: IAuthSignInPOJO;
|
||||
buildJob: any;
|
||||
}
|
||||
Reference in New Issue
Block a user