import {
ModuleWithProviders,
NgModule,
Optional,
SkipSelf
} from "@angular/core";
import { CommonModule } from "@angular/common";
import {
NbAuthModule,
NbDummyAuthStrategy,
NbPasswordAuthStrategy,
NbAuthJWTToken
} from "@nebular/auth";
import { NbSecurityModule, NbRoleProvider } from "@nebular/security";
import { of as observableOf } from "rxjs";
import { throwIfAlreadyLoaded } from "./module-import-guard";
import { DataModule } from "./data/data.module";
import { AnalyticsService } from "./utils/analytics.service";
import { environment } from './../../environments/environment';
const socialLinks = [
{
url: "https://github.com/akveo/nebular",
target: "_blank",
icon: "socicon-github"
},
{
url: "https://www.facebook.com/akveo/",
target: "_blank",
icon: "socicon-facebook"
},
{
url: "https://twitter.com/akveo_inc",
target: "_blank",
icon: "socicon-twitter"
}
];
export const NB_CORE_PROVIDERS = [
...DataModule.forRoot().providers,
...NbAuthModule.forRoot({
strategies: [
NbPasswordAuthStrategy.setup({
name: "email",
token: {
class: NbAuthJWTToken,
key: "token"
},
baseEndpoint: environment.apiEndpoint,
login: {
endpoint: "/login",
method: "post"
},
requestPass: {
endpoint: "/forgot",
method: "post",
redirect: {
success: '/auth/reset-password',
failure: null,
},
},
resetPass: {
endpoint: "/reset",
method: "put",
redirect: {
success: '/auth/login',
failure: null,
},
resetPasswordTokenKey: 'reset_password_token',
},
logout: {
alwaysFail: false,
endpoint: '/logout',
method: 'delete',
redirect: {
success: '/auth/login',
failure: null,
},
},
register: {
alwaysFail: false,
endpoint: '/register',
method: 'post',
redirect: {
success: '/auth/login',
failure: null,
},
}
})
],
forms: {
login: {
redirectDelay: 0,
strategy: 'email',
rememberMe: true,
showMessages: {
success: true,
},
},
register: {
redirectDelay: 0,
showMessages: {
success: true,
},
},
requestPassword: {
redirectDelay: 0,
showMessages: {
success: true,
},
},
resetPassword: {
redirectDelay: 0,
showMessages: {
success: true,
},
},
logout: {
redirectDelay: 500,
},
validation: {
name: {
required: true,
},
phone: {
required: true,
minLength: 8,
maxLength: 12,
},
password: {
required: true,
},
email: {
required: true
},
idNumber: {
required: true,
minLength: 8,
maxLength: 12,
},
},
}
}).providers,
AnalyticsService
];
@NgModule({
imports: [CommonModule],
exports: [NbAuthModule],
declarations: []
})
export class CoreModule {
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
throwIfAlreadyLoaded(parentModule, "CoreModule");
}
static forRoot(): ModuleWithProviders {
return <ModuleWithProviders>{
ngModule: CoreModule,
providers: [...NB_CORE_PROVIDERS]
};
}
}