mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
webui: createlogin with new pgpid
This commit is contained in:
parent
e944ab6045
commit
2fc35cf707
@ -3,6 +3,8 @@ var rs = require("retroshare");
|
|||||||
|
|
||||||
var locationName = "";
|
var locationName = "";
|
||||||
var password ="";
|
var password ="";
|
||||||
|
var ssl_name = "";
|
||||||
|
var newName = "";
|
||||||
|
|
||||||
function listprofiles(){
|
function listprofiles(){
|
||||||
var locations = rs("control/locations");
|
var locations = rs("control/locations");
|
||||||
@ -39,8 +41,47 @@ function setPasswd(passwd) {
|
|||||||
password = passwd;
|
password = passwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSslName(ssl) {
|
||||||
|
ssl_name = ssl;
|
||||||
|
}
|
||||||
|
|
||||||
function createLocation(loc) {
|
function setNewName(name) {
|
||||||
|
newName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkpasswd(){
|
||||||
|
var status = "";
|
||||||
|
var color = "red";
|
||||||
|
var lbl = document.getElementById("lblpwdinfo");
|
||||||
|
var passwd2 = document.getElementById("txtpasswd2").value;
|
||||||
|
if (passwd2 == password && passwd2 != "") {
|
||||||
|
color = "lime";
|
||||||
|
status = "password ok";
|
||||||
|
} else if (passwd2 == "") {
|
||||||
|
color = "yellow";
|
||||||
|
status = "password required";
|
||||||
|
} else {
|
||||||
|
color = "red";
|
||||||
|
status = "passwords don't match";
|
||||||
|
}
|
||||||
|
lbl.textContent = status;
|
||||||
|
lbl.style.color=color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function createLocation() {
|
||||||
|
var profile = m.route.param("id");
|
||||||
|
var profname = m.route.param("name");
|
||||||
|
|
||||||
|
var loc ={
|
||||||
|
ssl_name: document.getElementById("txtlocation").value,
|
||||||
|
pgp_password: password,
|
||||||
|
};
|
||||||
|
if (profile != undefined) {
|
||||||
|
loc.pgp_id= profile;
|
||||||
|
} else {
|
||||||
|
loc.pgp_name = newName;
|
||||||
|
};
|
||||||
rs.request("control/create_location",loc,function(data){
|
rs.request("control/create_location",loc,function(data){
|
||||||
m.route("/accountselect", {});
|
m.route("/accountselect", {});
|
||||||
});
|
});
|
||||||
@ -56,15 +97,75 @@ module.exports = {
|
|||||||
var hidden = m.route.param("hidden");
|
var hidden = m.route.param("hidden");
|
||||||
if (state == "wait"){
|
if (state == "wait"){
|
||||||
return m("div","waiting ...");
|
return m("div","waiting ...");
|
||||||
} else if (profile === undefined) {
|
} if (state == "newid"){
|
||||||
|
m.initControl = "txtnewname";
|
||||||
return m("div",[
|
return m("div",[
|
||||||
m("h2","create login - Step 1 / 2: select profile(PGP-ID)"),
|
m("h2","create login - Step 2 / 2: create location"),
|
||||||
|
m("h3","- for new profile "),
|
||||||
m("hr"),
|
m("hr"),
|
||||||
m("div.btn2",{} ,"<create new profile>"),
|
m("h2","PGP-profile name:"),
|
||||||
m("div.btn2",{} ,"<import profile (drag and drop a profile here)>"),
|
m("input",{
|
||||||
listprofiles()
|
id: "txtnewname",
|
||||||
]);
|
type:"text",
|
||||||
|
onchange:m.withAttr("value", setNewName),
|
||||||
|
onkeydown: function(event){
|
||||||
|
if (event.keyCode == 13){
|
||||||
|
document.getElementById("txtpasswd").focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
m("h2","enter password:"),
|
||||||
|
m("input", {
|
||||||
|
id: "txtpasswd",
|
||||||
|
type:"password",
|
||||||
|
onchange: m.withAttr("value",setPasswd),
|
||||||
|
onkeydown: function(event){
|
||||||
|
if (event.keyCode == 13){
|
||||||
|
setPasswd(this.value);
|
||||||
|
document.getElementById("txtpasswd2").focus();
|
||||||
};
|
};
|
||||||
|
checkpasswd;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
m("h2", "re-enter password:"),
|
||||||
|
m("input", {
|
||||||
|
id: "txtpasswd2",
|
||||||
|
type:"password",
|
||||||
|
onfocus: checkpasswd,
|
||||||
|
onchange: checkpasswd,
|
||||||
|
onkeyup: function(event){
|
||||||
|
if (event.keyCode == 13){
|
||||||
|
document.getElementById("txtlocation").focus();
|
||||||
|
}
|
||||||
|
checkpasswd();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
m("h3",{
|
||||||
|
id: "lblpwdinfo",
|
||||||
|
style:"color:yellow",
|
||||||
|
}, "password required"),
|
||||||
|
m("h2","location name:"),
|
||||||
|
m("input",{
|
||||||
|
id: "txtlocation",
|
||||||
|
type:"text",
|
||||||
|
onchange:m.withAttr("value", setLocationName),
|
||||||
|
onkeydown: function(event){
|
||||||
|
if (event.keyCode == 13){
|
||||||
|
setSslName(this.value);
|
||||||
|
createLocation();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
m("br"),
|
||||||
|
m("input",{
|
||||||
|
type: "button",
|
||||||
|
onclick: function(){
|
||||||
|
createLocation();
|
||||||
|
},
|
||||||
|
value: "create location",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
} else if (profile != undefined) {
|
||||||
m.initControl = "txtpasswd";
|
m.initControl = "txtpasswd";
|
||||||
return m("div",[
|
return m("div",[
|
||||||
m("h2","create login - Step 2 / 2: create location"),
|
m("h2","create login - Step 2 / 2: create location"),
|
||||||
@ -89,11 +190,8 @@ module.exports = {
|
|||||||
onchange:m.withAttr("value", setLocationName),
|
onchange:m.withAttr("value", setLocationName),
|
||||||
onkeydown: function(event){
|
onkeydown: function(event){
|
||||||
if (event.keyCode == 13){
|
if (event.keyCode == 13){
|
||||||
createLocation({
|
setSslName(this.value);
|
||||||
ssl_name: this.value,
|
createLocation();
|
||||||
pgp_id: profile,
|
|
||||||
pgp_password: password,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -101,10 +199,25 @@ module.exports = {
|
|||||||
m("input",{
|
m("input",{
|
||||||
type: "button",
|
type: "button",
|
||||||
onclick: function(){
|
onclick: function(){
|
||||||
createLocation(locationName);
|
createLocation();
|
||||||
},
|
},
|
||||||
value: "create location",
|
value: "create location",
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
} else {
|
||||||
|
return m("div",[
|
||||||
|
m("h2","create login - Step 1 / 2: select profile(PGP-ID)"),
|
||||||
|
m("hr"),
|
||||||
|
m("div.btn2",{
|
||||||
|
onclick: function(){
|
||||||
|
m.route("/createlogin", {state: "newid"});
|
||||||
|
},
|
||||||
|
} ,"<create new profile>"),
|
||||||
|
m("div.btn2",{
|
||||||
|
} ,"<import profile (drag and drop a profile here)>"),
|
||||||
|
listprofiles()
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user