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

Commit

Permalink
Added missing features and updated icons
Browse files Browse the repository at this point in the history
  • Loading branch information
liz3 committed Jun 5, 2017
1 parent b6d3b59 commit ee5bb5f
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 129 deletions.
8 changes: 4 additions & 4 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyApp</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
<widget id="de.liz3.passy" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<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 src="index.html" />
<access origin="*" />
<allow-navigation href="http://ionic.local/*" />
Expand Down
2 changes: 1 addition & 1 deletion ionic.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "mynewapp",
"name": "Passy",
"app_id": "",
"type": "ionic-angular"
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "mynewapp",
"name": "passy",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"author": "Liz3",
"homepage": "https://passy.pw",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
Expand Down Expand Up @@ -49,7 +49,7 @@
"@ionic/cli-plugin-ionic-angular": "1.3.0",
"typescript": "2.3.3"
},
"description": "An Ionic project",
"description": "The mobile App for the Passy Password Manager",
"cordova": {
"plugins": {
"cordova-plugin-http": {},
Expand Down
Binary file modified resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
297 changes: 205 additions & 92 deletions src/app/Passy.ts
Original file line number Diff line number Diff line change
@@ -1,148 +1,261 @@
import {Http, Headers, RequestOptions} from "@angular/http";
import {MyApp} from "./app.component";
import {loginScreen, popAlert} from "../pages/tabs/tabs";
export var passwords = [];
export var archived = [];
export var loggedIn = false;
export class Passy {

accessToken;
public loggedIn = false;
private _baseURL = "https://dev.liz3.net/passy-api/index.php";
accessToken;
public loggedIn = false;
private _baseURL = "https://dev.liz3.net/passy-api/index.php";

constructor(private app:MyApp) {
constructor() {


}
}

private request(http: Http, vals, callback) {

let opt: RequestOptions
let myHeaders: Headers = new Headers
myHeaders.set('Content-type', 'application/x-www-form-urlencoded');
opt = new RequestOptions({
headers: myHeaders
});

private request(http: Http, vals, callback) {
http.post(this._baseURL, this.buildRequestString(vals), opt).subscribe(response => {
callback(response);
})


}

let opt: RequestOptions
let myHeaders: Headers = new Headers
myHeaders.set('Content-type', 'application/x-www-form-urlencoded');
opt = new RequestOptions({
headers: myHeaders
});
public archive(http, id, callback) {

http.post(this._baseURL, this.buildRequestString(vals), opt).subscribe(response => {
callback(response);
})
const me = this;

this.request(http, [{name: "a", value: "password/archive"}, {name: "id", value: id}, {
name: "access_token",
value: this.accessToken
}], function (response) {

}
const json = JSON.parse(response.text());

private buildRequestString(data: any[]) {
if (json.success) {
me.fetchPasswords(http);
}
callback(json);
});

let response = "";
for (let i = 0; i != data.length; i++) {
const current = data[i];
if (response != "") response += "&";
response += encodeURIComponent(current.name) + "=" + encodeURIComponent(current.value);
}
return response;
}

public addPassword(http:Http, username, password, description, callback) {
private buildRequestString(data: any[]) {

const data = [{name: "a", value: "password/create"},
{ name: "access_token", value: this.accessToken},
{name: "username", value: username}, {name: "password", value: password}, {name: "description", value: description}];
let response = "";
for (let i = 0; i != data.length; i++) {
const current = data[i];
if (response != "") response += "&";
response += encodeURIComponent(current.name) + "=" + encodeURIComponent(current.value);
}
return response;
}

public addPassword(http: Http, username, password, description, callback) {

const me = this;
this.request(http, data, function (response) {
const data = [{name: "a", value: "password/create"},
{name: "access_token", value: this.accessToken},
{name: "username", value: username}, {name: "password", value: password}, {
name: "description",
value: description
}];

const json = JSON.parse(response.text());
if(json.success) {
me.fetchPasswords(http);
}
callback(json);
});
const me = this;
this.request(http, data, function (response) {

}
const json = JSON.parse(response.text());
if (json.success) {
me.fetchPasswords(http);
}
callback(json);
});

}

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

if (this.loggedIn) return;
if (this.loggedIn) return;

if (name != "" && pass != "") {
if (name != "" && pass != "") {

const me = this;
this.request(http, [{name: "a", value: "user/login"},
{name: "username", value: name}, {name: "password", value: pass}], function (response) {
const me = this;
this.request(http, [{name: "a", value: "user/login"},
{name: "username", value: name}, {name: "password", value: pass}], function (response) {


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

if (data.success) {
me.accessToken = data.token[0];
if (data.success) {
me.accessToken = data.token[0];

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

const 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(timer);
}

})

}, 2000);
} else {
popAlert("Failed", "Failed to login");
}

});

}

});
callBack(false);
}

public getPassword(id, http: Http, callback) {
if (!loggedIn) return "Error";

this.request(http, [
{name: "a", value: "password/query"}, {name: "id", value: id},
{
name: "access_token",
value: this.accessToken
}
], function (response) {

const json = JSON.parse(response.text());
callback(json.data.password);

});
}

public editPassword(id, username, password, description, http, callback) {

const me = this;
const data = [{name: "id", value: id},
{name: "a", value: "password/edit"},
{name: "username", value: username},
{name: "password", value: password},
{name: "description", value: description},
{name: "access_token", value: this.accessToken}];

this.request(http, data, function (response) {

const json = JSON.parse(response.text());
if (json.success) {
me.fetchPasswords(http);
}
callback(json);


});

}

callBack(false);
}
public restorePass(http, id, callback) {

const data = [{name: "a", value: "password/restore"}, {name: "id", value: id}, {
name: "access_token",
value: this.accessToken
}];
const me = this;

public getPassword(id, http:Http, callback) {
if(!loggedIn) return "Error";
this.request(http, data, function (response) {
if (response.success) {
me.fetchPasswords(http);
}
callback(JSON.parse(response.text()));
});

this.request(http, [
{name: "a", value: "password/query"},{name: "id", value: id},
{ name: "access_token",
value: this.accessToken
}
], function (response) {

const json = JSON.parse(response.text());
callback(json.data.password);
}

});
}
private fetchPasswords(http: Http) {
public delPass(http, id, callback) {

this.request(http, [{name: "a", value: "password/queryAll"}, {
name: "access_token",
value: this.accessToken
}], function (response) {
const data = [{name: "a", value: "password/delete"}, {name: "id", value: id}, {
name: "access_token",
value: this.accessToken
}];
const me = this;

const json = JSON.parse(response.text());
this.request(http, data, function (response) {
if (response.success) {
me.fetchPasswords(http);
}
callback(JSON.parse(response.text()));
});

passwords = json.data;

});
}

public fetchPasswords(http: Http) {

this.request(http, [{name: "a", value: "password/queryAll"}, {
name: "access_token",
value: this.accessToken
}], function (response) {

}
const json = JSON.parse(response.text());

const fetched = [];
const archive = [];
for (let i = 0; i != json.data.length; i++) {
const current = json.data[i];

if (current.archived) {
archive.push(current);
continue;
}
fetched.push(current);
}
archived = archive;
passwords = fetched;

});


}

}

export class Password {

private _id;
private _description;
private _username;
private _id;
private _description;
private _username;


constructor(id, description, username) {
this._id = id;
this._description = description;
this._username = username;
}
constructor(id, description, username) {
this._id = id;
this._description = description;
this._username = username;
}

get id() {
return this._id;
}
get id() {
return this._id;
}

get description() {
return this._description;
}
get description() {
return this._description;
}

get username() {
return this._username;
}
get username() {
return this._username;
}
}
Loading

0 comments on commit ee5bb5f

Please sign in to comment.