Skip to content

Commit

Permalink
Merge pull request #102 from ykoehler/support_anonymous
Browse files Browse the repository at this point in the history
Added support for Anonymous signIn
  • Loading branch information
r-park authored Nov 3, 2016
2 parents 4ec3423 + b692882 commit c709040
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/auth/components/sign-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AuthService } from '../services/auth-service';
<div class="g-row sign-in">
<div class="g-col">
<h1 class="sign-in__heading">Sign in</h1>
<button class="sign-in__button" (click)="signInAnonymously()" type="button">Anonymously</button>
<button class="sign-in__button" (click)="signInWithGithub()" type="button">GitHub</button>
<button class="sign-in__button" (click)="signInWithGoogle()" type="button">Google</button>
<button class="sign-in__button" (click)="signInWithTwitter()" type="button">Twitter</button>
Expand All @@ -22,6 +23,11 @@ import { AuthService } from '../services/auth-service';
export class SignInComponent {
constructor(private auth: AuthService, private router: Router) {}

signInAnonymously(): void {
this.auth.signInAnonymously()
.then(() => this.postSignIn());
}

signInWithGithub(): void {
this.auth.signInWithGithub()
.then(() => this.postSignIn());
Expand Down
10 changes: 9 additions & 1 deletion src/auth/services/auth-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { AuthProviders, FirebaseAuth, FirebaseAuthState } from 'angularfire2';
import { AuthProviders, AuthMethods, FirebaseAuth, FirebaseAuthState } from 'angularfire2';


@Injectable()
Expand All @@ -25,6 +25,14 @@ export class AuthService {
.catch(error => console.log('ERROR @ AuthService#signIn() :', error));
}

signInAnonymously(): firebase.Promise<FirebaseAuthState> {
return this.auth$.login({
provider: AuthProviders.Anonymous,
method: AuthMethods.Anonymous
})
.catch(error => console.log('ERROR @ AuthService#signInAnonymously() :', error));
}

signInWithGithub(): firebase.Promise<FirebaseAuthState> {
return this.signIn(AuthProviders.Github);
}
Expand Down

0 comments on commit c709040

Please sign in to comment.