Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { LogService } from './shared/log/log.service'
import { appConfig, DEFAULT_APP_CONFIG } from './shared/config/index' // TODO: check why barrel does not work?
bootstrap(AppComponent, [
APP_ROUTER_PROVIDER,
HTTP_PROVIDERS,
FIREBASE_PROVIDERS,
// Initialize Firebase app
defaultFirebase({
apiKey: "AIzaSyBxTIFIwi_rWHM3oeAtXSEi1nrEUvvlqu8",
authDomain: "investsystemsorg.firebaseapp.com",
databaseURL: "https://investsystemsorg.firebaseio.com",
storageBucket: "investsystemsorg.appspot.com",
}),
firebaseAuthConfig({
provider: AuthProviders.Google,
method: AuthMethods.Redirect
}),
// { provide: XHRBackend, useClass: InMemoryBackendService }, // in-mem server
// { provide: SEED_DATA, useClass: InMemoryDataService }, // in-mem server data
Title,
AuthGuard,
MdIconRegistry,
disableDeprecatedForms(),
provideForms(),
ChartsService,
SpinnerService,
LogService,
appConfig(DEFAULT_APP_CONFIG)
]).then(
() => window.console.info('Angular finished bootstrapping your application!'),
(error) => {
import {FIREBASE_PROVIDERS, defaultFirebase, firebaseAuthConfig, AuthProviders, AuthMethods, FirebaseListObservable} from 'angularfire2';
import {UserService} from './common/user.service';
import {AuthService, User} from './common/auth.service';
import {WebRTCConfig} from './common/webrtc.config';
import {WebRTCService} from './common/webrtc.service';
@App({
template: '',
config: {}, // http://ionicframework.com/docs/v2/api/config/Config/
providers: [
FIREBASE_PROVIDERS,
defaultFirebase('https://ng2-webrtc.firebaseio.com/'),
firebaseAuthConfig({
provider: AuthProviders.Google,
method: AuthMethods.Popup,
remember: 'default',
scope: ['email']
}),
WebRTCConfig, UserService, AuthService, WebRTCService],
})
export class MyApp {
// We show the fake page here and will change it after success authorization
rootPage: any = HomePage;
constructor(platform: Platform, webRTC: WebRTCService, authService:AuthService, userService:UserService) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
// Let's sign in first
form.get('email').setValue("test");
expect(form.get('email').valid).toEqual(false);
form.get('email').setValue("test@abc.com");
expect(form.get('email').valid).toEqual(true);
form.get('password').setValue("test");
expect(form.get('password').valid).toEqual(false);
form.get('password').setValue("Welcome321");
expect(form.get('password').valid).toEqual(true);
expect(form.valid).toEqual(true);
let user: FirebaseAuthState = {
"uid": _user.userId,
"provider" : AuthProviders.Google,
"auth": null
};
spyOn(af.auth, 'login')
.and.callFake((emailPass: any, method: any) => Promise.resolve(user))
let spy = spyOn(dRef, 'close')
.and.callFake(() => { });
comp.onSigninSubmit();
expect(af.auth.login).toHaveBeenCalled();
setTimeout(function() { //since the prior method is async call
expect(spy).toHaveBeenCalled();
},1000);
}));
private _getProvider(from: string) {
switch(from){
case 'twitter': return AuthProviders.Twitter;
case 'facebook': return AuthProviders.Facebook;
case 'github': return AuthProviders.Github;
case 'google': return AuthProviders.Google;
}
}
}
private _getProvider(from: string) {
switch (from) {
case 'twitter': return AuthProviders.Twitter;
case 'facebook': return AuthProviders.Facebook;
case 'github': return AuthProviders.Github;
case 'google': return AuthProviders.Google;
}
}
}
(dialog: MatDialog, af: AngularFire, dRef: MatDialogRef) => {
let spy = spyOn(af.auth, "login");
fixture.detectChanges();
let deButtons = fixture.debugElement.queryAll(By.css('button'));
deButtons[0].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Google, 'Provider Google');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
deButtons[1].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Facebook, 'Provider Facebook');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
deButtons[2].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Twitter, 'Provider Twitter');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
deButtons[3].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Github, 'Provider Github');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
signIn() {
this.af.auth.login({
provider: AuthProviders.Google,
method: AuthMethods.Popup
})
return this.af.auth;
}
getAuthProvider(provider: string): {} {
var authProvider = {method: AuthMethods.Redirect};
switch (provider){
case 'Google': authProvider['provider'] = AuthProviders.Google; break;
case 'Github': authProvider['provider'] = AuthProviders.Github; break;
case 'Facebook': authProvider['provider'] = AuthProviders.Facebook; break;
case 'Twitter': authProvider['provider'] = AuthProviders.Twitter; break;
default: return '{}';
}
return authProvider;
}
login() {
this.af.auth.login({
provider: AuthProviders.Google,
method: AuthMethods.Popup,
});
}