Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
- <title></title>
- <link href="lib/ionic/css/ionic.css" rel="stylesheet">
- <link href="css/style.css" rel="stylesheet">
- <script src="lib/ionic/js/ionic.bundle.min.js"></script>
- <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
- <script src="cordova.js"></script>
- <script src="lib/angular/angular.min.js"></script>
- <script src="js/app.js"></script>
- <script src="https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.min.js"></script>
- <script>
- (function() {
- var app = document.querySelector('#app');
- app.login = function() {
- var email = app.email;
- var password = app.password;
- if (!email || !password) {
- return console.log('email and password required');
- }
- // Sign in user
- firebase.auth().signInWithEmailAndPassword(email, password)
- .catch(function(error) {
- // Handle Errors here.
- var errorCode = error.code;
- var errorMessage = error.message;
- console.log('login error', error);
- // ...
- });
- };
- app.register = function() {
- var email = app.email;
- var password = app.password;
- if (!email || !password) {
- return console.log('email and password required');
- }
- // Register user
- firebase.auth().createUserWithEmailAndPassword(email, password)
- .catch(function(error) {
- console.log('register error', error);
- if (error.code === 'auth/email-already-in-use') {
- var credential = firebase.auth.EmailAuthProvider.credential(email, password);
- app.signInWithGoogle()
- .then(function() {
- firebase.auth().currentUser.link(credential)
- .then(function(user) {
- console.log("Account linking success", user);
- }, function(error) {
- console.log("Account linking error", error);
- });
- });
- }
- });
- };
- app.signOut = function() {
- // Sign out
- firebase.auth().signOut();
- };
- // Listen to auth state changes
- firebase.auth().onAuthStateChanged(function(user) {
- app.user = user;
- console.log('user', user);
- });
- })();
- </script>
- </head>
- <body ng-app="starter">
- <ion-pane>
- <ion-nav-bar class="bar-stable"></ion-nav-bar>
- <ion-nav-view></ion-nav-view>
- </ion-pane>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement