2 Commits 10dd3060fc ... 635b3cf4cd

Author SHA1 Message Date
  Esty Thomas 635b3cf4cd Merge branch 'ionic-branch' of notabug.org:estelendur/a2h22017 into ionic-branch 7 years ago
  Esty Thomas 6aff6d03ed Ionic serve works good now 7 years ago

BIN
mobile-hub-project.zip


+ 1 - 1
package.json

@@ -47,4 +47,4 @@
             "cordova-plugin-device-motion": {}
         }
     }
-}
+}

+ 0 - 32
src/app/app.component.spec.ts

@@ -1,32 +0,0 @@
-import { TestBed, async } from '@angular/core/testing';
-
-import { AppComponent } from './app.component';
-
-describe('AppComponent', () => {
-  beforeEach(async(() => {
-    TestBed.configureTestingModule({
-      declarations: [
-        AppComponent
-      ],
-    }).compileComponents();
-  }));
-
-  it('should create the app', async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.debugElement.componentInstance;
-    expect(app).toBeTruthy();
-  }));
-
-  it(`should have as title 'app'`, async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.debugElement.componentInstance;
-    expect(app.title).toEqual('app');
-  }));
-
-  it('should render title in a h1 tag', async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    fixture.detectChanges();
-    const compiled = fixture.debugElement.nativeElement;
-    expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!!');
-  }));
-});

+ 2 - 1
src/app/app.module.ts

@@ -1,5 +1,6 @@
 import { BrowserModule } from '@angular/platform-browser'; // TODO: Is this necessary?
 import { NgModule } from '@angular/core';
+import { IonicModule } from 'ionic-angular';
 import { AppComponent } from './app.component';
 import { DeviceMotion } from '@ionic-native/device-motion';
 import { IonicApp, IonicModule } from 'ionic-angular';
@@ -9,7 +10,7 @@ import { MomentModule } from 'angular2-moment';
   declarations: [AppComponent],
   imports: [
     BrowserModule, // TODO: Is this necessary?
-    IonicModule.forRoot(AppComponent),
+    IonicModule.forRoot(AppComponent, {}),
     MomentModule,
     AppComponent
   ],

+ 2 - 7
src/pages/settings/settings.ts

@@ -1,10 +1,7 @@
 import { Component } from '@angular/core';
 import { App } from 'ionic-angular';
-import { LoginPage } from '../login/login';
 import { AboutPage } from '../about/about';
-import { AccountPage } from '../account/account';
 
-import { User } from '../../providers/providers';
 
 @Component({
   templateUrl: 'settings.html'
@@ -12,14 +9,12 @@ import { User } from '../../providers/providers';
 export class SettingsPage {
 
   public aboutPage = AboutPage;
-  public accountPage = AccountPage;
 
-  constructor(public user: User, public app: App) {
+  constructor(public app: App) {
   }
 
   logout() {
-    this.user.logout();
-    this.app.getRootNav().setRoot(LoginPage);
+    this.app.getRootNav().setRoot(AboutPage);
   }
 
 }

+ 1 - 2
src/providers/providers.ts

@@ -1,5 +1,4 @@
-import { User } from './user';
 
 export {
-  User
+  
 };

+ 0 - 146
src/providers/user.ts

@@ -1,146 +0,0 @@
-import { Injectable } from '@angular/core';
-import { Config } from 'ionic-angular';
-
-import { Cognito } from './providers';
-
-declare var AWS: any;
-declare const aws_cognito_region;
-declare const aws_cognito_identity_pool_id;
-declare const aws_user_pools_id;
-declare const aws_user_pools_web_client_id;
-
-@Injectable()
-export class User {
-
-  private user: any;
-  public loggedIn: boolean = false;
-
-  constructor(public cognito: Cognito, public config: Config) {
-    this.user = null;
-  }
-
-  getUser() {
-    return this.user;
-  }
-
-  getUsername() {
-    return this.getUser().getUsername();
-  }
-
-  login(username, password) {
-    return new Promise((resolve, reject) => {
-      let user = this.cognito.makeUser(username);
-      let authDetails = this.cognito.makeAuthDetails(username, password);
-
-      user.authenticateUser(authDetails, {
-        'onSuccess': function(result) {
-          var logins = {};
-          var loginKey = 'cognito-idp.' +
-                          aws_cognito_region +
-                          '.amazonaws.com/' +
-                          aws_user_pools_id;
-          logins[loginKey] = result.getIdToken().getJwtToken();
-
-          AWS.config.credentials = new AWS.CognitoIdentityCredentials({
-           'IdentityPoolId': aws_cognito_identity_pool_id,
-           'Logins': logins
-          });
-
-          this.isAuthenticated().then(() => {
-            resolve();
-          }).catch((err) => {
-            console.log('auth session failed');
-          });
-        },
-
-        'onFailure': function(err) {
-          console.log('authentication failed');
-          reject(err);
-        }
-      });
-    });
-  }
-
-  logout() {
-    this.user = null;
-    this.cognito.getUserPool().getCurrentUser().signOut();
-  }
-
-  register(username, password, attr) {
-    let attributes = [];
-
-    for (var x in attr) {
-      attributes.push(this.cognito.makeAttribute(x, attr[x]));
-    }
-
-    return new Promise((resolve, reject) => {
-      this.cognito.getUserPool().signUp(username, password, attributes, null, function(err, result) {
-        if (err) {
-          reject(err);
-        } else {
-          resolve(result.user);
-        }
-      });
-    });
-  }
-
-  confirmRegistration(username, code) {
-    return new Promise((resolve, reject) => {
-      let user = this.cognito.makeUser(username);
-      user.confirmRegistration(code, true, (err, result) => {
-            if (err) {
-              console.log('could not confirm user', err);
-              reject(err);
-            } else {
-              resolve(result);
-            }
-        });
-    });
-  }
-
-  resendRegistrationCode(username) {
-    return new Promise((resolve, reject) => {
-      let user = this.cognito.makeUser(username);
-      user.resendConfirmationCode((err, result) => {
-        if (err) {
-          console.log('could not resend code..', err);
-          reject(err);
-        } else {
-          resolve();
-        }
-      });
-    });
-  }
-
-  isAuthenticated() {
-    return new Promise((resolve, reject) => {
-      let user = this.cognito.getCurrentUser();
-      if (user != null) {
-        user.getSession((err, session) => {
-          if (err) {
-            console.log('rejected session');
-            reject()
-          } else {
-            console.log('accepted session');
-            var logins = {};
-            var loginKey = 'cognito-idp.' +
-              aws_cognito_region +
-              '.amazonaws.com/' +
-              aws_user_pools_id;
-            logins[loginKey] = session.getIdToken().getJwtToken();
-
-            AWS.config.credentials = new AWS.CognitoIdentityCredentials({
-              'IdentityPoolId': aws_cognito_identity_pool_id,
-              'Logins': logins
-            });
-
-            this.user = user;
-            resolve()
-          }
-        });
-      } else {
-        reject()
-      }
-    });
-  }
-}

+ 0 - 0
src/service-worker.js