Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding firebase 3.x authentication methods #882

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
440db1a
feat(storage): Add bindings for Firebase Storage
davideast Aug 16, 2016
8ab2b7b
fix(storage): Linting errors
davideast Aug 16, 2016
28e7baa
Adds protractor storage test
abeisgoat Aug 16, 2016
e477f7b
chore(tests): Storage tests
davideast Aug 17, 2016
2d49d40
feat(storage): Add tests
davideast Sep 20, 2016
82aa1ae
feat(storage): .utils tests
davideast Sep 20, 2016
77679c0
feat(storage): tests
davideast Sep 20, 2016
d2978d9
feat(storage): Add FirebaseStorageDirective
davideast Oct 18, 2016
424ee4f
chore(storage): Merge conflicts
davideast Oct 18, 2016
9624b5b
chore(tests): Include pertinent source files for coverage. MockTask t…
davideast Nov 9, 2016
42a7a3c
fix(build): Add scripts to package.json
davideast Nov 10, 2016
c9b18ae
Adding firebase 3.x authentication methods
Nov 17, 2016
d0a60ad
Adding firebase 3.x authentication methods
Nov 17, 2016
1b24c95
Merge remote-tracking branch 'refs/remotes/origin/feature/firebase-3-…
idanen Nov 17, 2016
56f3c1a
fix(tests): npm script for test
davideast Nov 21, 2016
e02bf4c
Update CDN firebase link to 3.6.0 version (#883)
Loksly Nov 21, 2016
01ea208
fix(tests): Travis tests
davideast Nov 21, 2016
84056b5
Fix dead link to introduction-to-angularfire.md#handling-asynchronous…
puf Dec 6, 2016
99fbb40
Fix firebaseObject destroyed caused delayed on('value') update failur…
ulion Dec 20, 2016
32cdf6d
Updated angular-mocks dependency to fix unit test failures (#890)
Dec 20, 2016
74e8506
Actually run the Travis tests and upgrade dependencies (#891)
Dec 20, 2016
fffdc0c
Added requireEmailVerification argument to $requireSignIn() (#887)
ericmorgan1 Dec 21, 2016
486de1c
Added release notes for upcoming 2.2.0 release (#892)
Dec 21, 2016
7c7beab
[firebase-release] Updated AngularFire to 2.2.0
firebase-ops Dec 21, 2016
1ca8796
[firebase-release] Removed change log and reset repo after 2.2.0 release
firebase-ops Dec 21, 2016
c22ef72
Fixed table of contents link for requireSignIn() in reference docs (#…
Dec 21, 2016
6cecd43
Merge branch 'master' into storage
davideast Dec 23, 2016
f425523
chore(tests): Refactor class to Module Pattern for ES5
davideast Dec 23, 2016
ddb7258
fix(tests): Use correct test database
davideast Dec 23, 2016
8621d25
chore(tests): Remove upload test
davideast Dec 30, 2016
3cdc6e2
chore(tests): Refactor from Jacob's comments
davideast Jan 6, 2017
da501f5
chore(build): Travis yml
davideast Jan 6, 2017
8bd3a44
fix(build): Remove improper char
davideast Jan 6, 2017
4cdd779
chore(tests): Set upload e2e to manual
davideast Jan 9, 2017
4b15969
chore(tests): Changes per Jacob's comments
davideast Jan 10, 2017
da9a148
chore(tests): Remove ES6 syntax
davideast Jan 10, 2017
e584905
chore(refactor): , , and other comments from Jacob
davideast Jan 11, 2017
ce4f392
chore(tests): Refactor tests per Jacob's comments
davideast Jan 12, 2017
9881546
Merge pull request #865 from firebase/storage
davideast Jan 12, 2017
f2e8333
Fixed incorrect information in code comments for router docs (#899)
idanb11 Jan 12, 2017
94ca5bc
Updated $signInWithPopup(), $signInWithRedirect(), and $signInWithCre…
Jan 12, 2017
8c6b932
Adding firebase 3.x authentication methods
Nov 17, 2016
644914c
Merge remote-tracking branch 'refs/remotes/origin/feature/firebase-3-…
idanen Jan 19, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ install:
- npm install
before_script:
- grunt install
- phantomjs --version
script:
- sh ./tests/travis.sh
after_script:
- cat ./tests/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
env:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ In order to use AngularFire in your project, you need to include the following f

```html
<!-- AngularJS -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.min.js"></script>

<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/3.4.1/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.6.4/firebase.js"></script>

<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/2.1.0/angularfire.min.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/2.2.0/angularfire.min.js"></script>
```

You can also install AngularFire via npm and Bower and its dependencies will be downloaded
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/introduction-to-angularfire.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ AngularFire bindings from our CDN:

```html
<!-- Angular -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.min.js"></script>

<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.6.4/firebase.js"></script>

<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/2.0.1/angularfire.min.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/2.2.0/angularfire.min.js"></script>
```

Firebase and AngularFire are also available via npm and Bower as `firebase` and `angularfire`,
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/user-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ app.config(["$routeProvider", function($routeProvider) {
// Auth refers to our $firebaseAuth wrapper in the factory below
"currentAuth": ["Auth", function(Auth) {
// $requireSignIn returns a promise so the resolve waits for it to complete
// If the promise is rejected, it will throw a $stateChangeError (see above)
// If the promise is rejected, it will throw a $routeChangeError (see above)
return Auth.$requireSignIn();
}]
}
Expand All @@ -336,7 +336,7 @@ app.controller("HomeCtrl", ["currentAuth", function(currentAuth) {

app.controller("AccountCtrl", ["currentAuth", function(currentAuth) {
// currentAuth (provided by resolve) will contain the
// authenticated user or null if not signed in
// authenticated user or throw a $routeChangeError (see above) if not signed in
}]);

app.factory("Auth", ["$firebaseAuth",
Expand Down Expand Up @@ -398,7 +398,7 @@ app.controller("HomeCtrl", ["currentAuth", function(currentAuth) {

app.controller("AccountCtrl", ["currentAuth", function(currentAuth) {
// currentAuth (provided by resolve) will contain the
// authenticated user or null if not signed in
// authenticated user or throw a $stateChangeError (see above) if not signed in
}]);

app.factory("Auth", ["$firebaseAuth",
Expand Down
8 changes: 4 additions & 4 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ In order to use AngularFire in a project, include the following script tags:

```html
<!-- Angular -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.min.js"></script>

<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.6.4/firebase.js"></script>

<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/2.0.1/angularfire.min.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/2.2.0/angularfire.min.js"></script>
```

Firebase and AngularFire are also available via npm and Bower as `firebase` and `angularfire`,
Expand Down Expand Up @@ -76,7 +76,7 @@ In the example above, `$scope.data` is going to be populated from the remote ser
asynchronous call, so it will take some time before the data becomes available in the controller.
While it might be tempting to put a `console.log` on the next line to read the results, the data
won't be downloaded yet, so the object will appear to be empty. Read the section on
[Asynchronous Operations](guide/introduction-to-angularfire.html#handling-asynchronous-operations) for more details.
[Asynchronous Operations](guide/introduction-to-angularfire.md#handling-asynchronous-operations) for more details.


## 5. Add Three-Way, Object Bindings
Expand Down
126 changes: 94 additions & 32 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* [`$sendPasswordResetEmail(email)`](#sendpasswordresetemailemail)
* Router Helpers
* [`$waitForSignIn()`](#waitforsignin)
* [`$requireSignIn()`](#requiresignin)
* [`$requireSignIn(requireEmailVerification)`](#requiresigninrequireemailverification)
* [Extending the Services](#extending-the-services)
* [Extending `$firebaseObject`](#extending-firebaseobject)
* [Extending `$firebaseArray`](#extending-firebasearray)
Expand Down Expand Up @@ -686,11 +686,14 @@ for more details about email / password authentication.

### $signInWithPopup(provider)

Authenticates the client using a popup-based OAuth flow. This function takes two
arguments: the unique string identifying the OAuth provider to authenticate with (e.g. `"google"`).
Authenticates the client using a popup-based OAuth flow. This function takes a single argument: a
a string or provider object representing the OAuth provider to authenticate with. It returns a
promise which is resolved or rejected when the authentication attempt is completed. If successful,
the promise will be fulfilled with an object containing authentication data about the signed-in
user. If unsuccessful, the promise will be rejected with an `Error` object.

Optionally, you can pass a provider object (like `new firebase.auth.GoogleAuthProvider()`, etc)
which can be configured with additional options.
Valid values for the string version of the argument are `"facebook"`, `"github"`, `"google"`, and
`"twitter"`:

```js
$scope.authObj.$signInWithPopup("google").then(function(result) {
Expand All @@ -700,45 +703,100 @@ $scope.authObj.$signInWithPopup("google").then(function(result) {
});
```

This method returns a promise which is resolved or rejected when the authentication attempt is
completed. If successful, the promise will be fulfilled with an object containing authentication
data about the signed-in user. If unsuccessful, the promise will be rejected with an `Error` object.
Alternatively, you can request certain scopes or custom parameters from the OAuth provider by
passing a provider object (such as `new firebase.auth.GoogleAuthProvider()`) configured with
additional options:

```js
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope("https://www.googleapis.com/auth/plus.login");
provider.setCustomParameters({
login_hint: "user@example.com"
});

$scope.authObj.$signInWithPopup(provider).then(function(result) {
console.log("Signed in as:", result.user.uid);
}).catch(function(error) {
console.error("Authentication failed:", error);
});
```

Firebase currently supports Facebook, GitHub, Google, and Twitter authentication. Refer to
[authentication documentation](https://firebase.google.com/docs/auth/)
for information about configuring each provider.
Firebase currently supports [Facebook](https://firebase.google.com/docs/auth/web/facebook-login),
[GitHub](https://firebase.google.com/docs/auth/web/github-auth),
[Google](https://firebase.google.com/docs/auth/web/google-signin),
and [Twitter](https://firebase.google.com/docs/auth/web/twitter-login) authentication. Refer to the
linked documentation in the previous sentence for information about configuring each provider.

### $signInWithRedirect(provider[, options])

Authenticates the client using a redirect-based OAuth flow. This function takes two
arguments: the unique string identifying the OAuth provider to authenticate with (e.g. `"google"`).
Authenticates the client using a redirect-based OAuth flow. This function takes a single argument: a
string or provider object representing the OAuth provider to authenticate with. It returns a
rejected promise with an `Error` object if the authentication attempt fails. Upon successful
authentication, the browser will be redirected as part of the OAuth authentication flow. As such,
the returned promise will never be fulfilled. Instead, you should use the `$onAuthStateChanged()`
method to detect when the authentication has been successfully completed.

Optionally, you can pass a provider object (like `new firebase.auth().GoogleProvider()`, etc)
which can be configured with additional options.
Valid values for the string version of the argument are `"facebook"`, `"github"`, `"google"`, and
`"twitter"`:

```js
$scope.authObj.$signInWithRedirect("google").then(function() {
// Never called because of page redirect
// Instead, use $onAuthStateChanged() to detect successful authentication
}).catch(function(error) {
console.error("Authentication failed:", error);
});
```

This method returns a rejected promise with an `Error` object if the authentication attempt fails.
Upon successful authentication, the browser will be redirected as part of the OAuth authentication
flow. As such, the returned promise will never be fulfilled. Instead, you should use the `$onAuthStateChanged()`
method to detect when the authentication has been successfully completed.
Alternatively, you can request certain scopes or custom parameters from the OAuth provider by
passing a provider object (such as `new firebase.auth.GoogleAuthProvider()`) configured with
additional options:

Firebase currently supports Facebook, GitHub, Google, and Twitter authentication. Refer to
[authentication documentation](https://firebase.google.com/docs/auth/)
for information about configuring each provider.
```js
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope("https://www.googleapis.com/auth/plus.login");
provider.setCustomParameters({
login_hint: "user@example.com"
});

$scope.authObj.$signInWithRedirect(provider).then(function(result) {
// Never called because of page redirect
// Instead, use $onAuthStateChanged() to detect successful authentication
}).catch(function(error) {
console.error("Authentication failed:", error);
});
```

Firebase currently supports [Facebook](https://firebase.google.com/docs/auth/web/facebook-login),
[GitHub](https://firebase.google.com/docs/auth/web/github-auth),
[Google](https://firebase.google.com/docs/auth/web/google-signin),
and [Twitter](https://firebase.google.com/docs/auth/web/twitter-login) authentication. Refer to the
linked documentation in the previous sentence for information about configuring each provider.

### $signInWithCredential(credential)

Authenticates the client using a credential (potentially created from OAuth Tokens). This function takes one
arguments: the credential object. This may be obtained from individual auth providers under `firebase.auth()`;
Authenticates the client using a credential. This function takes a single argument: the credential
object. Credential objects are created from a provider-specific set of user data, such as their
email / password combination or an OAuth access token.

```js
// Email / password authentication with credential
var credential = firebase.auth.EmailAuthProvider.credential(email, password);

$scope.authObj.$signInWithCredential(credential).then(function(firebaseUser) {
console.log("Signed in as:", firebaseUser.uid);
}).catch(function(error) {
console.error("Authentication failed:", error);
});
```

```js
// Facebook authentication with credential
var credential = firebase.auth.FacebookAuthProvider.credential(
// `event` come from the Facebook SDK's auth.authResponseChange() callback
event.authResponse.accessToken
);

$scope.authObj.$signInWithCredential(credential).then(function(firebaseUser) {
console.log("Signed in as:", firebaseUser.uid);
}).catch(function(error) {
Expand All @@ -750,9 +808,14 @@ This method returns a promise which is resolved or rejected when the authenticat
completed. If successful, the promise will be fulfilled with an object containing authentication
data about the signed-in user. If unsuccessful, the promise will be rejected with an `Error` object.

Firebase currently supports Facebook, GitHub, Google, and Twitter authentication. Refer to
[authentication documentation](https://firebase.google.com/docs/auth/)
for information about configuring each provider.
Firebase currently supports `$signInWithCredential()` for the
[email / password](https://firebase.google.com/docs/reference/node/firebase.auth.EmailAuthProvider#.credential),
[Facebook](https://firebase.google.com/docs/reference/node/firebase.auth.FacebookAuthProvider#.credential),
[GitHub](https://firebase.google.com/docs/reference/node/firebase.auth.GithubAuthProvider#.credential),
[Google](https://firebase.google.com/docs/reference/node/firebase.auth.GoogleAuthProvider#.credential),
and [Twitter](https://firebase.google.com/docs/reference/node/firebase.auth.TwitterAuthProvider#.credential)
authentication providers. Refer to the linked documentation in the previous sentence for information
about creating a credential for each provider.

### $getAuth()

Expand Down Expand Up @@ -894,16 +957,15 @@ intended to be used in the `resolve()` method of Angular routers. See the
["Using Authentication with Routers"](/docs/guide/user-auth.md#authenticating-with-routers)
section of our AngularFire guide for more information and a full example.

### $requireSignIn()
### $requireSignIn(requireEmailVerification)

Helper method which returns a promise fulfilled with the current authentication state if the user
is authenticated but otherwise rejects the promise. This is intended to be used in the `resolve()`
method of Angular routers to prevented unauthenticated users from seeing authenticated pages
momentarily during page load. See the
is authenticated and, if specified, has a verified email address, but otherwise rejects the promise.
This is intended to be used in the `resolve()` method of Angular routers to prevent unauthenticated
users from seeing authenticated pages momentarily during page load. See the
["Using Authentication with Routers"](/docs/guide/user-auth.md#authenticating-with-routers)
section of our AngularFire guide for more information and a full example.


## Extending the Services

There are several powerful techniques for transforming the data downloaded and saved
Expand Down
37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,31 @@
},
"devDependencies": {
"angular": "^1.3.0",
"angular-mocks": "~1.4.6",
"angular-mocks": "^1.6.0",
"coveralls": "^2.11.2",
"grunt": "~0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.9.0",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-karma": "^0.10.1",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-karma": "^2.0.0",
"grunt-notify": "^0.4.1",
"grunt-protractor-runner": "^1.2.1",
"grunt-protractor-runner": "^4.0.0",
"grunt-shell-spawn": "^0.3.1",
"jasmine-core": "^2.2.0",
"jasmine-spec-reporter": "^2.1.0",
"karma": "~0.12.31",
"karma-chrome-launcher": "^0.2.2",
"karma-coverage": "^0.2.7",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-failed-reporter": "0.0.3",
"karma-firefox-launcher": "^0.1.4",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "~0.1.4",
"karma-sauce-launcher": "~0.2.10",
"karma-spec-reporter": "0.0.16",
"karma-firefox-launcher": "^1.0.0",
"karma-html2js-preprocessor": "^1.1.0",
"karma-jasmine": "^1.1.0",
"karma-sauce-launcher": "^1.1.0",
"karma-spec-reporter": "^0.0.26",
"load-grunt-tasks": "^3.1.0",
"protractor": "^1.6.1"
"protractor": "^4.0.13"
}
}
Loading