Skip to content
This repository has been archived by the owner on Jun 4, 2018. It is now read-only.

Commit

Permalink
Added 2fa, fixed bugs.
Browse files Browse the repository at this point in the history
Its not a huge commit, but now, the app will work with 2fa enabled, also the app will save the passy url.
Also fixed a bug on login with Android and repositioned the random button on new password.
  • Loading branch information
liz3 committed Sep 10, 2017
1 parent 7823de0 commit b3ef745
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 116 deletions.
3 changes: 2 additions & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<name>Passy</name>
<description>The mobile App for the Passy Password Manager</description>
<author email="[email protected]" href="https://passy.pw">Passy Team</author>
<content original-src="index.html" src="http://192.168.178.45:8100" />
<content src="index.html" />
<access origin="*" />
<allow-navigation href="http://ionic.local/*" />
<allow-intent href="http://*/*" />
Expand Down Expand Up @@ -81,6 +81,7 @@
<allow-navigation href="http://192.168.178.45:8100" />
<engine name="android" spec="^6.2.3" />
<engine name="ios" spec="^4.4.0" />
<plugin name="cordova-clipboard" spec="^1.0.0" />
<plugin name="cordova-plugin-console" spec="^1.0.7" />
<plugin name="cordova-plugin-device" spec="^1.1.6" />
<plugin name="cordova-plugin-http" spec="^1.2.0" />
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@ionic-native/touch-id": "^4.2.1",
"@ionic/storage": "^2.0.1",
"cordova-android": "^6.2.3",
"cordova-clipboard": "^1.0.0",
"cordova-ios": "^4.4.0",
"cordova-plugin-compat": "^1.1.0",
"cordova-plugin-console": "^1.0.7",
Expand Down Expand Up @@ -63,7 +64,8 @@
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-touch-id": {},
"cordova-sqlite-storage": {}
"cordova-sqlite-storage": {},
"cordova-clipboard": {}
},
"platforms": [
"android",
Expand Down
70 changes: 69 additions & 1 deletion src/app/Passy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Http, Headers, RequestOptions} from "@angular/http";
import {loginScreen, popAlert} from "../pages/tabs/tabs";
import {AlertController} from "ionic-angular";

export var passwords = [];
export var archived = [];
Expand Down Expand Up @@ -119,7 +120,7 @@ export class Passy {

}

public tryLogin(name: string, pass: string, http: Http, callBack, loader) {
public tryLogin(name: string, pass: string, http: Http, callBack, loader, alertController:AlertController) {

if (this.loggedIn) return;

Expand All @@ -134,6 +135,7 @@ export class Passy {
const data = JSON.parse(response.text());

if (data.success) {

me.accessToken = data.token[0];

me.fetchPasswords(http);
Expand All @@ -159,6 +161,72 @@ export class Passy {

}, 2000);
} else {
if(data.msg == "two_factor_needed") {

let twoFaPrompt = alertController.create({
title: 'Login',
inputs: [
{
name: 'code',
placeholder: 'Two Factor Code'
}
],
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: data => {
callBack(false);
return;
}
},
{
text: 'Login',
handler: data => {

me.request(http, [{name: "a", value: "user/login"},
{name: "username", value: name}, {name: "password", value: pass}, {name: "2faCode", value: data.code}], (response) => {

const data = JSON.parse(response.text());

me.accessToken = data.token[0];

me.fetchPasswords(http);
loggedIn = true;
callBack(true);

me.timer = setInterval(function () {
me.request(http, [{name: "access_token", value: me.accessToken}, {
name: "a",
value: "status"
}], function (response) {

const json = JSON.parse(response.text());
if (!json.data.logged_in) {
passwords = [];
archived = [];
me.accessToken = "";
loginScreen();
clearInterval(me.timer);
}

})

}, 2000);


});

return;
}
}
]
});
twoFaPrompt.present();


return;
}
loader.dismissAll();
popAlert("Failed", "Failed to login");
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {EditPassPage} from "../pages/edit-password/edit-pass";
import {ArchivePage} from "../pages/archived/archive";
import {TouchID} from "@ionic-native/touch-id";
import {IonicStorageModule} from "@ionic/storage";
import {Clipboard} from "@ionic-native/clipboard";


@NgModule({
Expand Down Expand Up @@ -52,7 +53,8 @@ import {IonicStorageModule} from "@ionic/storage";
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
TouchID
TouchID,
Clipboard


]
Expand Down
80 changes: 41 additions & 39 deletions src/pages/home/home.html
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
<ion-header>
<ion-toolbar>
<ion-title>Passwords</ion-title>
<ion-buttons end>
<button (click)="logout()" ion-button icon-only color="royal">
<ion-icon name="log-out"></ion-icon>
</button>
<button (click)="addPass()" ion-button icon-only color="royal">
<ion-icon name="add"></ion-icon>
</button>
</ion-buttons>
</ion-toolbar>
<ion-toolbar>
<ion-title>Passwords</ion-title>
<ion-buttons start>
<button (click)="addPass()" ion-button icon-only color="royal">
<ion-icon name="add"></ion-icon>
</button>
</ion-buttons>
<ion-buttons end>
<button (click)="logout()" ion-button icon-only color="royal">
<ion-icon name="log-out"></ion-icon>
</button>

</ion-buttons>
</ion-toolbar>
</ion-header>

<ion-content padding>

<ion-searchbar (ionInput)="search($event)" [(ngModel)]="searchText"></ion-searchbar>

<div *ngFor="let current of passwords">
<ion-card *ngIf="current.totalVis">

<ion-card-header>
{{current.username || "None"}}
</ion-card-header>

<ion-card-content>
<p>{{current.description || "None"}}</p>
<br />
<ion-buttons start>
<button *ngIf="current.vis" (click)="showPass(current.password_id, current)" ion-button icon-only>
<ion-icon name="eye"></ion-icon>
</button>
<button *ngIf="!current.vis" ion-button icon-only>
<ion-spinner item-start></ion-spinner>
</button>
<button (click)="more(current)" ion-button icon-only color="transparent">
<ion-icon name="add"></ion-icon>
</button>
</ion-buttons>
</ion-card-content>

</ion-card>
</div>

<ion-searchbar (ionInput)="search($event)" [(ngModel)]="searchText"></ion-searchbar>

<div *ngFor="let current of passwords">
<ion-card *ngIf="current.totalVis">

<ion-card-header>
{{current.username || "None"}}
</ion-card-header>

<ion-card-content>
<p>{{current.description || "None"}}</p>
<br/>
<ion-buttons start>
<button *ngIf="current.vis" (click)="showPass(current.password_id, current)" ion-button icon-only>
<ion-icon name="eye"></ion-icon>
</button>
<button *ngIf="!current.vis" ion-button icon-only>
<ion-spinner item-start></ion-spinner>
</button>
<button (click)="more(current)" ion-button icon-only color="transparent">
<ion-icon name="add"></ion-icon>
</button>
</ion-buttons>
</ion-card-content>

</ion-card>
</div>


</ion-content>
100 changes: 56 additions & 44 deletions src/pages/login/LoginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export class LoginPage {


constructor(public viewCtrl: ViewController, public http: Http, private touchId: TouchID, public storage: Storage, public alertCtrl: AlertController, public loadingCtrl: LoadingController) {

const me = this;
storage.get("save_url").then(val => {
if(val != null && val.length > 5) me.target = val;
})
}


Expand All @@ -34,51 +39,58 @@ export class LoginPage {
passy.tryLogin(this.username, this.password, this.http, function (succeeded) {
loader.dismissAll();
if (succeeded) {
if (isCordovaAvailable()) {
me.storage.keys().then(keys => {


if (keys.indexOf("touch_dismiss") == -1) {
let confirm = me.alertCtrl.create({
title: 'Enable Touch ID Login?',
message: 'Do you want to be able to login with touch id?',
buttons: [{
text: 'Disagree',
handler: () => {
me.storage.set("touch_dismiss", true).then(_ => {
me.dismiss()

});

}
},
{
text: 'Agree',
handler: () => {
me.storage.set("touch_save", true).then(_ => {
me.storage.set("touch_user", me.username).then(_ => {
me.storage.set("touch_pass", me.password).then(_ => {
me.dismiss();
});
});
});
}
}]
});
confirm.present();
} else {
me.dismiss()

}

});

} else {
me.dismiss();
}
me.storage.set("save_url", me.target).then(_ => {
if (isCordovaAvailable()) {
me.storage.keys().then(keys => {


if (keys.indexOf("touch_dismiss") == -1) {

me.touchId.isAvailable().then(_ => {
let confirm = me.alertCtrl.create({
title: 'Enable Touch ID Login?',
message: 'Do you want to be able to login with touch id?',
buttons: [{
text: 'Disagree',
handler: () => {
me.storage.set("touch_dismiss", true).then(_ => {
me.dismiss()

});

}
},
{
text: 'Agree',
handler: () => {
me.storage.set("touch_save", true).then(_ => {
me.storage.set("touch_user", me.username).then(_ => {
me.storage.set("touch_pass", me.password).then(_ => {
me.dismiss();
});
});
});
}
}]
});
confirm.present();
}).catch(_ => {
me.dismiss();
});
} else {
me.dismiss();

}

});

} else {
me.dismiss();
}
})
}

}, loader);
}, loader, this.alertCtrl);
}

ionViewDidLoad() {
Expand Down Expand Up @@ -107,7 +119,7 @@ export class LoginPage {
loader.dismissAll();
it.dismiss()
}
});
}, loader, this.alertCtrl);
})
})
},
Expand Down
Loading

0 comments on commit b3ef745

Please sign in to comment.