Add OAuth Login facebook,google,github

This commit is contained in:
Qolzam
2017-11-18 19:04:31 +07:00
parent f64b7bb24d
commit 92379b615c
23 changed files with 513 additions and 264 deletions

View File

@@ -1,7 +1,9 @@
import { LoginUser } from './loginResult'
import { OAuthType } from './oauthType'
import { LoginUser } from './loginUser'
import { RegisterUserResult } from './registerUserResult'
export {
LoginUser,
RegisterUserResult
}
RegisterUserResult,
OAuthType
}

View File

@@ -1,23 +0,0 @@
import { BaseDomain } from 'core/domain/common'
export class LoginUser extends BaseDomain {
constructor (private _uid: string, private _emailVerified: boolean) {
super()
}
/**
* User identifier
*
* @type {string}
* @memberof LoginUser
*/
public get uid (): string {
return this._uid
}
public get emailVerified (): boolean {
return this._emailVerified
}
}

View File

@@ -0,0 +1,54 @@
import { BaseDomain } from 'core/domain/common'
export class LoginUser extends BaseDomain {
constructor (
private _uid: string,
private _emailVerified: boolean,
private _providerId: string = '',
private _displayName: string = '',
private _email: string = '',
private _avatarURL: string = ''
) {
super()
}
/**
* User identifier
*
* @type {string}
* @memberof LoginUser
*/
public get uid (): string {
return this._uid
}
/**
* If user's email is verifide {true} or not {false}
*
* @readonly
* @type {boolean}
* @memberof LoginUser
*/
public get emailVerified (): boolean {
return this._emailVerified
}
public get providerId (): string {
return this._providerId
}
public get displayName (): string {
return this._displayName
}
public get email (): string {
return this.email
}
public get avatarURL (): string {
return this._avatarURL
}
}

View File

@@ -0,0 +1,5 @@
export enum OAuthType {
GITHUB = 'GITHUB',
FACEBOOK = 'FACEBOOK',
GOOGLE = 'GOOGLE'
}

View File

@@ -1,23 +1,21 @@
import { BaseDomain } from 'core/domain/common'
export class RegisterUserResult extends BaseDomain{
export class RegisterUserResult extends BaseDomain {
constructor(uid: string){
super()
private _uid: string
constructor (uid: string) {
super()
this._uid = uid
}
this._uid = uid
}
/**
* User identifier
*
*
* @type {string}
* @memberof LoginUser
*/
private _uid : string
public get uid (): string {
return this._uid
}
}
public get uid (): string {
return this._uid
}
}

View File

@@ -1,7 +1,9 @@
import {User} from './user'
import {Profile} from './profile'
import { User } from './user'
import { Profile } from './profile'
import { UserProvider } from './userProvider'
export {
User,
Profile
}
Profile,
UserProvider
}

View File

@@ -1,45 +1,14 @@
import { BaseDomain } from 'core/domain/common'
export class Profile extends BaseDomain {
constructor (
public avatar: string,
public fullName: string,
public banner: string,
public tagLine: string,
public email?: string | null) {
super()
/**
* User avatar address
*
* @type {string}
* @memberof Profile
*/
public avatar: string
/**
* User email
*
* @type {string}
* @memberof Profile
*/
public email?: string | null
/**
* User full name
*
* @type {string}
* @memberof Profile
*/
public fullName: string
/**
* The banner address of user profile
*
* @type {string}
* @memberof Profile
*/
public banner: string
/**
* User tag line
*
* @type {string}
* @memberof Profile
*/
public tagLine: string
}
}

View File

@@ -0,0 +1,18 @@
/**
* User provide data
*
* @export
* @class UserProvider
*/
export class UserProvider {
constructor (
public userId: string,
public email: string,
public fullName: string,
public avatar: string,
public providerId: string,
public provider: string,
public accessToken: string
) {}
}

View File

@@ -1,5 +1,5 @@
import { User } from 'core/domain/users'
import { LoginUser, RegisterUserResult } from 'core/domain/authorize'
import { LoginUser, RegisterUserResult, OAuthType } from 'core/domain/authorize'
/**
* Authentication service interface
@@ -55,4 +55,11 @@ export interface IAuthorizeService {
* @memberof IAuthorizeService
*/
sendEmailVerification: () => Promise<void>
/**
* Login user by OAuth authentication
*
* @memberof IAuthorizeService
*/
loginWithOAuth: (type: OAuthType) => Promise<LoginUser>
}