This repository has been archived by the owner on Jun 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing features and updated icons
- Loading branch information
liz3
committed
Jun 5, 2017
1 parent
b6d3b59
commit ee5bb5f
Showing
16 changed files
with
395 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/*" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "mynewapp", | ||
"name": "Passy", | ||
"app_id": "", | ||
"type": "ionic-angular" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.