├── src ├── pages │ ├── home │ │ ├── home.scss │ │ ├── home.html │ │ ├── home.ts │ │ └── authservice.ts │ ├── signup │ │ ├── signup.scss │ │ ├── signup.html │ │ └── signup.ts │ └── userpage │ │ ├── userpage.scss │ │ ├── userpage.html │ │ └── userpage.ts ├── assets │ └── icon │ │ └── favicon.ico ├── app │ ├── main.dev.ts │ ├── main.prod.ts │ ├── app.component.ts │ ├── app.scss │ └── app.module.ts ├── manifest.json ├── declarations.d.ts ├── index.html ├── theme │ └── variables.scss └── service-worker.js ├── resources ├── icon.png ├── splash.png ├── ios │ ├── icon │ │ ├── icon.png │ │ ├── icon-40.png │ │ ├── icon-50.png │ │ ├── icon-60.png │ │ ├── icon-72.png │ │ ├── icon-76.png │ │ ├── icon@2x.png │ │ ├── icon-40@2x.png │ │ ├── icon-50@2x.png │ │ ├── icon-60@2x.png │ │ ├── icon-60@3x.png │ │ ├── icon-72@2x.png │ │ ├── icon-76@2x.png │ │ ├── icon-small.png │ │ ├── icon-small@2x.png │ │ └── icon-small@3x.png │ └── splash │ │ ├── Default-667h.png │ │ ├── Default-736h.png │ │ ├── Default~iphone.png │ │ ├── Default@2x~iphone.png │ │ ├── Default-568h@2x~iphone.png │ │ ├── Default-Landscape-736h.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default-Portrait~ipad.png │ │ ├── Default-Landscape@2x~ipad.png │ │ └── Default-Portrait@2x~ipad.png └── android │ ├── icon │ ├── drawable-hdpi-icon.png │ ├── drawable-ldpi-icon.png │ ├── drawable-mdpi-icon.png │ ├── drawable-xhdpi-icon.png │ ├── drawable-xxhdpi-icon.png │ └── drawable-xxxhdpi-icon.png │ └── splash │ ├── drawable-land-hdpi-screen.png │ ├── drawable-land-ldpi-screen.png │ ├── drawable-land-mdpi-screen.png │ ├── drawable-land-xhdpi-screen.png │ ├── drawable-port-hdpi-screen.png │ ├── drawable-port-ldpi-screen.png │ ├── drawable-port-mdpi-screen.png │ ├── drawable-port-xhdpi-screen.png │ ├── drawable-land-xxhdpi-screen.png │ ├── drawable-land-xxxhdpi-screen.png │ ├── drawable-port-xxhdpi-screen.png │ └── drawable-port-xxxhdpi-screen.png ├── ionic.config.json ├── README.md ├── tslint.json ├── .editorconfig ├── tsconfig.json ├── .gitignore ├── package.json └── config.xml /src/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | page-home { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /src/pages/signup/signup.scss: -------------------------------------------------------------------------------- 1 | page-signup { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /src/pages/userpage/userpage.scss: -------------------------------------------------------------------------------- 1 | page-userpage { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/icon.png -------------------------------------------------------------------------------- /resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/splash.png -------------------------------------------------------------------------------- /ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "newauth", 3 | "app_id": "", 4 | "v2": true, 5 | "typescript": true 6 | } 7 | -------------------------------------------------------------------------------- /resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /src/assets/icon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/src/assets/icon/favicon.ico -------------------------------------------------------------------------------- /resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ionic2-authentication 2 | An updated version of REST Api Authentication in Ionic 2 apps. 3 | 4 | For further details - http://tphangout.com/?p=434 5 | -------------------------------------------------------------------------------- /resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rajayogan/ionic2-authentication/HEAD/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /src/app/main.dev.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app.module'; 4 | 5 | platformBrowserDynamic().bootstrapModule(AppModule); 6 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-duplicate-variable": true, 4 | "no-unused-variable": [ 5 | true 6 | ] 7 | }, 8 | "rulesDirectory": [ 9 | "node_modules/tslint-eslint-rules/dist/rules" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/app/main.prod.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowser } from '@angular/platform-browser'; 2 | import { enableProdMode } from '@angular/core'; 3 | 4 | import { AppModuleNgFactory } from './app.module.ngfactory'; 5 | 6 | enableProdMode(); 7 | platformBrowser().bootstrapModuleFactory(AppModuleNgFactory); 8 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ionic", 3 | "short_name": "Ionic", 4 | "start_url": "index.html", 5 | "display": "standalone", 6 | "icons": [{ 7 | "src": "assets/imgs/logo.png", 8 | "sizes": "512x512", 9 | "type": "image/png" 10 | }], 11 | "background_color": "#4e8ef7", 12 | "theme_color": "#4e8ef7" 13 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | # We recommend you to keep these unchanged 11 | end_of_line = lf 12 | charset = utf-8 13 | trim_trailing_whitespace = true 14 | insert_final_newline = true 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": true, 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "lib": [ 8 | "dom", 9 | "es2015" 10 | ], 11 | "module": "es2015", 12 | "moduleResolution": "node", 13 | "target": "es5" 14 | }, 15 | "exclude": [ 16 | "node_modules" 17 | ], 18 | "compileOnSave": false, 19 | "atom": { 20 | "rewriteTsconfig": false 21 | } 22 | } -------------------------------------------------------------------------------- /src/pages/userpage/userpage.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | userpage 11 | 12 | 13 | 14 | 15 | 16 | 17 |

You are logged in

18 | 19 | 20 |
21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .sass-cache/ 17 | .tmp/ 18 | .versions/ 19 | coverage/ 20 | dist/ 21 | node_modules/ 22 | tmp/ 23 | temp/ 24 | hooks/ 25 | platforms/ 26 | plugins/ 27 | plugins/android.json 28 | plugins/ios.json 29 | www/ 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { Platform } from 'ionic-angular'; 3 | import { StatusBar } from 'ionic-native'; 4 | 5 | import { HomePage } from '../pages/home/home'; 6 | 7 | 8 | @Component({ 9 | template: `` 10 | }) 11 | export class MyApp { 12 | rootPage = HomePage; 13 | 14 | constructor(platform: Platform) { 15 | platform.ready().then(() => { 16 | // Okay, so the platform is ready and our plugins are available. 17 | // Here you can do any higher level native things you might need. 18 | StatusBar.styleDefault(); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ionic Blank 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Username 13 | 14 | 15 | 16 | Password 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/declarations.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Declaration files are how the Typescript compiler knows about the type information(or shape) of an object. 3 | They're what make intellisense work and make Typescript know all about your code. 4 | 5 | A wildcard module is declared below to allow third party libraries to be used in an app even if they don't 6 | provide their own type declarations. 7 | 8 | To learn more about using third party libraries in an Ionic app, check out the docs here: 9 | http://ionicframework.com/docs/v2/resources/third-party-libs/ 10 | 11 | For more info on type definition files, check out the Typescript docs here: 12 | https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html 13 | */ 14 | declare module '*'; -------------------------------------------------------------------------------- /src/app/app.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Global Sass 5 | // -------------------------------------------------- 6 | // Put style rules here that you want to apply globally. These 7 | // styles are for the entire app and not just one component. 8 | // Additionally, this file can be also used as an entry point 9 | // to import other Sass files to be included in the output CSS. 10 | // 11 | // Shared Sass variables, which can be used to adjust Ionic's 12 | // default Sass variables, belong in "theme/variables.scss". 13 | // 14 | // To declare rules for a specific mode, create a child rule 15 | // for the .md, .ios, or .wp mode classes. The mode class is 16 | // automatically applied to the element in the app. 17 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { IonicApp, IonicModule } from 'ionic-angular'; 3 | import { MyApp } from './app.component'; 4 | import { HomePage } from '../pages/home/home'; 5 | import {Userpage} from '../pages/userpage/userpage'; 6 | import {Signup} from '../pages/signup/signup'; 7 | import {AuthService} from '../pages/home/authservice'; 8 | 9 | @NgModule({ 10 | declarations: [ 11 | MyApp, 12 | HomePage, 13 | Userpage, 14 | Signup 15 | ], 16 | imports: [ 17 | IonicModule.forRoot(MyApp) 18 | ], 19 | bootstrap: [IonicApp], 20 | entryComponents: [ 21 | MyApp, 22 | HomePage, 23 | Userpage, 24 | Signup 25 | ], 26 | providers: [AuthService] 27 | }) 28 | export class AppModule {} 29 | -------------------------------------------------------------------------------- /src/pages/signup/signup.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | signup 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Username 20 | 21 | 22 | 23 | Password 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { NavController } from 'ionic-angular'; 4 | 5 | import {AuthService} from './authservice'; 6 | import {Userpage} from '../userpage/userpage'; 7 | import {Signup} from '../signup/signup'; 8 | 9 | @Component({ 10 | selector: 'page-home', 11 | templateUrl: 'home.html' 12 | }) 13 | export class HomePage { 14 | 15 | usercreds = { 16 | name: '', 17 | password: '' 18 | }; 19 | 20 | constructor(public navCtrl: NavController, public authservice: AuthService) { 21 | 22 | 23 | 24 | } 25 | 26 | login(user) { 27 | this.authservice.authenticate(user).then(data => { 28 | if(data) { 29 | this.navCtrl.setRoot(Userpage); 30 | } 31 | }); 32 | } 33 | signup() { 34 | this.navCtrl.push(Signup); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/pages/signup/signup.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { NavController, AlertController } from 'ionic-angular'; 3 | import {AuthService} from '../home/authservice'; 4 | 5 | 6 | /* 7 | Generated class for the Signup page. 8 | 9 | See http://ionicframework.com/docs/v2/components/#navigation for more info on 10 | Ionic pages and navigation. 11 | */ 12 | @Component({ 13 | selector: 'page-signup', 14 | templateUrl: 'signup.html' 15 | }) 16 | export class Signup { 17 | newcreds = { 18 | name: '', 19 | password: '' 20 | } 21 | constructor(public navCtrl: NavController, public authservice: AuthService, public alertCtrl: AlertController) { 22 | 23 | 24 | 25 | 26 | } 27 | 28 | register(user) { 29 | this.authservice.adduser(user).then(data => { 30 | if(data) { 31 | var alert = this.alertCtrl.create({ 32 | title: 'Success', 33 | subTitle: 'User Created', 34 | buttons: ['ok'] 35 | }); 36 | alert.present(); 37 | } 38 | }); 39 | } 40 | 41 | 42 | ionViewDidLoad() { 43 | console.log('Hello Signup Page'); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/pages/userpage/userpage.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { NavController, AlertController } from 'ionic-angular'; 3 | import {AuthService} from '../home/authservice'; 4 | import {HomePage} from '../home/home'; 5 | 6 | 7 | /* 8 | Generated class for the Userpage page. 9 | 10 | See http://ionicframework.com/docs/v2/components/#navigation for more info on 11 | Ionic pages and navigation. 12 | */ 13 | @Component({ 14 | selector: 'page-userpage', 15 | templateUrl: 'userpage.html' 16 | }) 17 | export class Userpage { 18 | 19 | constructor(public navCtrl: NavController, public authservice: AuthService, public alertCtrl: AlertController) {} 20 | 21 | logout() { 22 | this.authservice.logout(); 23 | this.navCtrl.setRoot(HomePage); 24 | } 25 | 26 | getinfo() { 27 | this.authservice.getinfo().then(data => { 28 | if(data.success) { 29 | var alert = this.alertCtrl.create({ 30 | title: data.success, 31 | subTitle: data.msg, 32 | buttons: ['ok'] 33 | }); 34 | alert.present(); 35 | } 36 | 37 | }) 38 | } 39 | 40 | 41 | ionViewDidLoad() { 42 | console.log('Hello Userpage Page'); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-hello-world", 3 | "author": "Ionic Framework", 4 | "homepage": "http://ionicframework.com/", 5 | "private": true, 6 | "scripts": { 7 | "build": "ionic-app-scripts build", 8 | "watch": "ionic-app-scripts watch", 9 | "serve:before": "watch", 10 | "emulate:before": "build", 11 | "deploy:before": "build", 12 | "build:before": "build", 13 | "run:before": "build" 14 | }, 15 | "dependencies": { 16 | "@angular/common": "^2.0.0", 17 | "@angular/compiler": "^2.0.0", 18 | "@angular/compiler-cli": "^0.6.2", 19 | "@angular/core": "^2.0.0", 20 | "@angular/forms": "^2.0.0", 21 | "@angular/http": "^2.0.0", 22 | "@angular/platform-browser": "^2.0.0", 23 | "@angular/platform-browser-dynamic": "^2.0.0", 24 | "@angular/platform-server": "^2.0.0", 25 | "ionic-angular": "^2.0.0-rc.0", 26 | "ionicons": "^3.0.0", 27 | "@ionic/storage": "^1.0.3", 28 | "ionic-native": "^2.0.3", 29 | "rxjs": "^5.0.0-beta.12", 30 | "zone.js": "^0.6.21" 31 | }, 32 | "devDependencies": { 33 | "@ionic/app-scripts": "latest", 34 | "typescript": "^2.0.3" 35 | }, 36 | "description": "newauth: An Ionic project", 37 | "cordovaPlugins": [ 38 | "cordova-plugin-device", 39 | "cordova-plugin-console", 40 | "cordova-plugin-whitelist", 41 | "cordova-plugin-splashscreen", 42 | "cordova-plugin-statusbar", 43 | "ionic-plugin-keyboard" 44 | ], 45 | "cordovaPlatforms": [] 46 | } 47 | -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | newauth 4 | An awesome Ionic/Cordova app. 5 | Ionic Framework Team 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/v2/theming/ 3 | @import "ionic.globals"; 4 | 5 | 6 | // Shared Variables 7 | // -------------------------------------------------- 8 | // To customize the look and feel of this app, you can override 9 | // the Sass variables found in Ionic's source scss files. 10 | // To view all the possible Ionic variables, see: 11 | // http://ionicframework.com/docs/v2/theming/overriding-ionic-variables/ 12 | 13 | $text-color: #000; 14 | $background-color: #fff; 15 | 16 | 17 | // Named Color Variables 18 | // -------------------------------------------------- 19 | // Named colors makes it easy to reuse colors on various components. 20 | // It's highly recommended to change the default colors 21 | // to match your app's branding. Ionic uses a Sass map of 22 | // colors so you can add, rename and remove colors as needed. 23 | // The "primary" color is the only required color in the map. 24 | 25 | $colors: ( 26 | primary: #387ef5, 27 | secondary: #32db64, 28 | danger: #f53d3d, 29 | light: #f4f4f4, 30 | dark: #222, 31 | favorite: #69BB7B 32 | ); 33 | 34 | 35 | // App iOS Variables 36 | // -------------------------------------------------- 37 | // iOS only Sass variables can go here 38 | 39 | 40 | 41 | 42 | // App Material Design Variables 43 | // -------------------------------------------------- 44 | // Material Design only Sass variables can go here 45 | 46 | 47 | 48 | 49 | // App Windows Variables 50 | // -------------------------------------------------- 51 | // Windows only Sass variables can go here 52 | 53 | 54 | 55 | 56 | // App Theme 57 | // -------------------------------------------------- 58 | // Ionic apps can have different themes applied, which can 59 | // then be future customized. This import comes last 60 | // so that the above variables are used and Ionic's 61 | // default are overridden. 62 | 63 | @import "ionic.theme.default"; 64 | 65 | 66 | // Ionicons 67 | // -------------------------------------------------- 68 | // The premium icon font for Ionic. For more info, please see: 69 | // http://ionicframework.com/docs/v2/ionicons/ 70 | 71 | $ionicons-font-path: "../assets/fonts"; 72 | @import "ionicons"; 73 | -------------------------------------------------------------------------------- /src/pages/home/authservice.ts: -------------------------------------------------------------------------------- 1 | import {Injectable, Inject} from '@angular/core'; 2 | import {Http, Headers} from '@angular/http'; 3 | 4 | @Injectable() 5 | export class AuthService { 6 | 7 | isLoggedin: boolean; 8 | AuthToken; 9 | 10 | constructor(public http: Http) { 11 | this.http = http; 12 | this.isLoggedin = false; 13 | this.AuthToken = null; 14 | } 15 | 16 | storeUserCredentials(token) { 17 | window.localStorage.setItem('raja', token); 18 | this.useCredentials(token); 19 | 20 | } 21 | 22 | useCredentials(token) { 23 | this.isLoggedin = true; 24 | this.AuthToken = token; 25 | } 26 | 27 | loadUserCredentials() { 28 | var token = window.localStorage.getItem('raja'); 29 | this.useCredentials(token); 30 | } 31 | 32 | destroyUserCredentials() { 33 | this.isLoggedin = false; 34 | this.AuthToken = null; 35 | window.localStorage.clear(); 36 | } 37 | 38 | authenticate(user) { 39 | var creds = "name=" + user.name + "&password=" + user.password; 40 | var headers = new Headers(); 41 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); 42 | 43 | return new Promise(resolve => { 44 | this.http.post('http://localhost:3333/authenticate', creds, {headers: headers}).subscribe(data => { 45 | if(data.json().success){ 46 | this.storeUserCredentials(data.json().token); 47 | resolve(true); 48 | } 49 | else 50 | resolve(false); 51 | }); 52 | }); 53 | } 54 | adduser(user) { 55 | var creds = "name=" + user.name + "&password=" + user.password; 56 | var headers = new Headers(); 57 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); 58 | 59 | return new Promise(resolve => { 60 | this.http.post('http://localhost:3333/adduser', creds, {headers: headers}).subscribe(data => { 61 | if(data.json().success){ 62 | resolve(true); 63 | } 64 | else 65 | resolve(false); 66 | }); 67 | }); 68 | } 69 | 70 | getinfo() { 71 | return new Promise(resolve => { 72 | var headers = new Headers(); 73 | this.loadUserCredentials(); 74 | console.log(this.AuthToken); 75 | headers.append('Authorization', 'Bearer ' +this.AuthToken); 76 | this.http.get('http://localhost:3333/getinfo', {headers: headers}).subscribe(data => { 77 | if(data.json().success) 78 | resolve(data.json()); 79 | else 80 | resolve(false); 81 | }); 82 | }) 83 | } 84 | 85 | logout() { 86 | this.destroyUserCredentials(); 87 | } 88 | } -------------------------------------------------------------------------------- /src/service-worker.js: -------------------------------------------------------------------------------- 1 | // tick this to make the cache invalidate and update 2 | const CACHE_VERSION = 1; 3 | const CURRENT_CACHES = { 4 | 'read-through': 'read-through-cache-v' + CACHE_VERSION 5 | }; 6 | 7 | self.addEventListener('activate', (event) => { 8 | // Delete all caches that aren't named in CURRENT_CACHES. 9 | // While there is only one cache in this example, the same logic will handle the case where 10 | // there are multiple versioned caches. 11 | const expectedCacheNames = Object.keys(CURRENT_CACHES).map((key) => { 12 | return CURRENT_CACHES[key]; 13 | }); 14 | 15 | event.waitUntil( 16 | caches.keys().then((cacheNames) => { 17 | return Promise.all( 18 | cacheNames.map((cacheName) => { 19 | if (expectedCacheNames.indexOf(cacheName) === -1) { 20 | // If this cache name isn't present in the array of "expected" cache names, then delete it. 21 | console.log('Deleting out of date cache:', cacheName); 22 | return caches.delete(cacheName); 23 | } 24 | }) 25 | ); 26 | }) 27 | ); 28 | }); 29 | 30 | // This sample illustrates an aggressive approach to caching, in which every valid response is 31 | // cached and every request is first checked against the cache. 32 | // This may not be an appropriate approach if your web application makes requests for 33 | // arbitrary URLs as part of its normal operation (e.g. a RSS client or a news aggregator), 34 | // as the cache could end up containing large responses that might not end up ever being accessed. 35 | // Other approaches, like selectively caching based on response headers or only caching 36 | // responses served from a specific domain, might be more appropriate for those use cases. 37 | self.addEventListener('fetch', (event) => { 38 | 39 | event.respondWith( 40 | caches.open(CURRENT_CACHES['read-through']).then((cache) => { 41 | return cache.match(event.request).then((response) => { 42 | if (response) { 43 | // If there is an entry in the cache for event.request, then response will be defined 44 | // and we can just return it. 45 | 46 | return response; 47 | } 48 | 49 | // Otherwise, if there is no entry in the cache for event.request, response will be 50 | // undefined, and we need to fetch() the resource. 51 | console.log(' No response for %s found in cache. ' + 52 | 'About to fetch from network...', event.request.url); 53 | 54 | // We call .clone() on the request since we might use it in the call to cache.put() later on. 55 | // Both fetch() and cache.put() "consume" the request, so we need to make a copy. 56 | // (see https://fetch.spec.whatwg.org/#dom-request-clone) 57 | return fetch(event.request.clone()).then((response) => { 58 | 59 | // Optional: add in extra conditions here, e.g. response.type == 'basic' to only cache 60 | // responses from the same domain. See https://fetch.spec.whatwg.org/#concept-response-type 61 | if (response.status < 400 && response.type === 'basic') { 62 | // We need to call .clone() on the response object to save a copy of it to the cache. 63 | // (https://fetch.spec.whatwg.org/#dom-request-clone) 64 | cache.put(event.request, response.clone()); 65 | } 66 | 67 | // Return the original response object, which will be used to fulfill the resource request. 68 | return response; 69 | }); 70 | }).catch((error) => { 71 | // This catch() will handle exceptions that arise from the match() or fetch() operations. 72 | // Note that a HTTP error response (e.g. 404) will NOT trigger an exception. 73 | // It will return a normal response object that has the appropriate error code set. 74 | console.error(' Read-through caching failed:', error); 75 | 76 | throw error; 77 | }); 78 | }) 79 | ); 80 | }); --------------------------------------------------------------------------------