小黒小波比.nodejsパスワードの探し出し方----携帯電話は探し出します.


サービス:
基本フレーム
//    :
tel: {
	attribute: { //              
	},
	method: function(e) {
		var _ = this.apis;

		//          
		app.awf.task({
			//     sql  
			//       task
		}).task({ //     sql  
			//       task
		}).task({
			//     sql  
			//       task
		}).task({
			//     sql  
			//       task
		}).task({
			//     sql  
			//       task
		}).await({ 
			//                     });}
		});
	}
}
tel:{
},//    
code:{
}
下に私のサービス先のjsコードを貼り付けます.
/**
 * sign  auth   
 *
 *        
 *
 *     http://127.0.0.1:9080/api/admin/passwordrecover.tel?params={"tel":"22222"}
 *     http://127.0.0.1:9080/api/admin/person.save?params={"e":"[email protected]","t":"13811641164","s":"1","n":"lyb"}
 * @category  task
 * @class auth
 * @namespace task.sign
 * @author SDark
 * @since
 *  2014.09.09 lyb           
 */

var task = {};

task.code = "admin.passwordrecover";

task.name = "admin.passwordrecover";

task.description = "         ";

/**
 *   api 
 */
task.deps = {
	sql: "common.sql",
	sqlls: "common.biz",
	msg: "common.msg"
};
/**
 *     
 * @attribute attribute
 */
task.attribute = {};

task.tasks = {
	tel: {
		attribute: {
			//"user":true
		},
		method: function(e) {
			var _ = this.apis;
			//       
			//var utype = 1;//e.action.user.utype;
			//          
			app.awf.task({
				code: "One",
				method: function(ex) {
					var sql = "select * from userbase where telphone=:telphone";
					console.info(sql)
					_.sqlls.query(sql, {
						telphone: e.params.tel
					}).success(function(rows) {
						if (rows.length <= 0) {
							ex.error("       !<br/>        !");
							ex.failure({
								data: false
							});
						} else {
							ex.success({
								data: true
							});
						}
					}).failure(function(err) {
						ex.error(err);
					});
				}
				/*

				console.log(result);
				function addNumber(_idx) {
					var str = '';
					for (var i = 0; i < _idx; i += 1) {
						str += Math.floor(Math.random() * 10);
					}
					return str;
				}
				addNumber(6);
				console.log(addNumber(6));
				e.result({
					status:1
					//       ,        {}
					//status:1//            , a:status

				});
			}).failure(function(){
				console.log("     !  !failure");
				e.result({
					status:2
				});
		}*/
			}).task({
				code: "Two",
				method: function(ex) { //             ,        ,          
					var sql = "select * from user_check where telphone=:telphone and status=1 and :now<=timeout and :now>=createtime";
					console.info(sql)
					_.sqlls.query(sql, {
						telphone: e.params.Tel,
						now: Date.now() - 946684800000
					}).success(function(rows) {
						if (rows.length > 0) {
							ex.error("            ,      !");
						} else {
							ex.success({
								data: true
							});
						}
					}).failure(function(err) {
						ex.error(err);
					});
				}

			}).task({
				code: "Three",
				method: function(ex) { //         
					var sql = "update user_check set status=3 where telphone=:telphone";
					console.info(sql)
					_.sqlls.query(sql, {
						telphone: e.params.Tel
					}).success(function(rows) {
						ex.success({
							data: true
						});
					}).failure(function(err) {
						ex.error(err);
					});
				}

			}).task({
				code: "Four",
				method: function(ex) { //    
					var syspassword = addNumber(6); //     ,          
					function addNumber(_idx) {//         js     
						var str = '';
						for (var i = 0; i < _idx; i += 1) {
							str += Math.floor(Math.random() * 10);
						}
						return str;
					}<pre name="code" class="javascript"><span style="white-space:pre">					</span>// _.msg.send(e.params.Tel,
					// 	syspassword
					// ).success(function(rows) {
					// 	ex.success({
					// 		data: syspassword
					// 	});
					// }).failure(function(err) {
					// 	ex.error(err);
					// });
					ex.success({
						data: syspassword
					});
				}
			}).task({
				code: "Five",
				method: function(ex) { //     
					var sql = "insert into user_check(telphone,checkinfo,timeout,createtime,status) values(:telphone,:checkinfo,:timeout,:createtime,1);";
					console.log(sql);
					_.sqlls.query(sql, {
						telphone: e.params.tel,
						checkinfo: ex.get("Four").data,
						timeout: Date.now() - 946684800000 + 100000,
						createtime: Date.now() - 946684800000
					}).success(function(rows) {
						ex.success({
							data: true
						});
					}).failure(function(err) {
						ex.error(err);
					});
				}
			}).await({
				success: function(ex) {
					e.result({
						"successTag": true
					});
				},
				failure: function(ex) {
					e.result({
						"successTag": false,
						"msg": ex.toString().replace("Error:", "")
					});
				}
			});

		}
	}, //            
 
  
 
 
 
//     
	code: {
		attribute: {

		},
		method: function(e) { //         
			var _ = this.apis;
			console.info(e.params.StuPhone);
			console.info(e.params.ValidateCode);
			var sql = "select iid from user_check where telphone=:telphone and status=1 and checkinfo=:checkinfo and :now<=timeout and :now>=createtime;";
			//var sql = "select count(*) as a from user_check where telphone=:telphone and status=1 and checkinfo=:checkinfo"
			_.sqlls.query(sql, {
				telphone: e.params.StuPhone,
				now: Date.now() - 946684800000,
				checkinfo: e.params.ValidateCode
			}).success(function(row) {
				console.info(row);
				if (row.length > 0) {
					console.log("  !" + row);
					e.result(
						row
					);
				} else {
					console.log("      !     !");
					e.result({
						status: 2
					});
				}
				/*if (rows[0]["a"] > 0) {   count(*)
					console.log("  !");
					e.result({
						status: 1
					});
				} else {
					//e.error("      !     !");
					console.log("      !     !");
					e.result({
						status: 2
					});
				};*/
			}).failure(function() {
				console.log("  !");
				e.result({
					status: 3
				});
			});
		}
	},
//    
	save: {
		attribute: {

		},
		method: function(e) {
			var _ = this.apis;
			var sql1 = "select iid from user_check where checkinfo=:checkinfo"
			var sql = "update userbase set upassword=:pwd where telphone=:tel;";
			console.log(e.params.tel);
			console.log(e.params.code);
			_.sqlls.query(sql1, {
				checkinfo: e.params.code
			}).success(function(result) {<pre name="code" class="javascript"><span style="white-space:pre">					</span>_.sqlls.save(sql, {
					pwd: e.params.pwd,
					tel: e.params.tel //  
				}).success(function(result) {
					console.log("  !!");
					e.result({ //  
						"successTag": true
					});
				}).failure(function() {
					console.log("  !");
					e.result({
						"successTag": false
					});
				});
			}).failure(function() {
				console.log("  !");
					e.result({
						"successTag": false
					});
			});


		}
	}
};
exports.task = task;
 
 
 
  
 

客户端的js

var RefreshTool = function(arg, tel, code) { //             ,                        
        _("#Last").attr("tel", "");//        
        _("#Last").attr("code", "");//        

        if (arg == 1) {
            _("#Setp1").css("background", "url('Context/images/password/u6.png')")
            _("#Setp2").css("background", "url('Context/images/password/u36.png')")
            _("#Setp3").css("background", "url('Context/images/password/u0.png')")
            _("#Setp1 img").attr("src", "Context/images/password/u4.png")
            _("#Setp2 img").attr("src", "Context/images/password/u4.png")
            _("#Setp3 img").attr("src", "Context/images/password/u44.png")
            _("#Last").hide();
            _("#First").show();
        } else if (arg == 2) {
            _("#Setp1").css("background", "url('Context/images/password/u36.png')")
            _("#Setp2").css("background", "url('Context/images/password/u6.png')")
            _("#Setp3").css("background", "url('Context/images/password/u0.png')")
            _("#Setp1 img").attr("src", "Context/images/password/u44.png")
            _("#Setp2 img").attr("src", "Context/images/password/u44.png")
            _("#Setp3 img").attr("src", "Context/images/password/u4.png")
            _("#First").hide();
        } else {
            _("#Setp1").css("background", "url('Context/images/password/u0.png')")
            _("#Setp2").css("background", "url('Context/images/password/u36.png')")
            _("#Setp3").css("background", "url('Context/images/password/u6.png')")
            _("#Setp1 img").attr("src", "Context/images/password/u8.png")
            _("#Setp2 img").attr("src", "Context/images/password/u8.png")
            _("#Setp3 img").attr("src", "Context/images/password/u44.png")
            _("#Email").hide();
            _("#Phone").hide();
            _("#Last").attr("tel", tel);//        
            _("#Last").attr("code", code);//       
            _("#Last").show();
        }
    };
    var wait = 0;
    var events = {
        ByEmail: function(sender, arg) { //      
            RefreshTool(2);
            _("#Email").show();
        },
        ByTel: function(sender, arg) { //      
            RefreshTool(2);
            _("#Phone").show();
        },
        EmailOK: function(sender, arg) { //         
            RefreshTool(3);
        },
        CodeOK: function(sender, arg) {
            if (wait > 0) return;
            wait = 60;
            var tel = _('[data-item="telphone"]', events.parent).val(); //    [name="tel"] [data-item="telphone"]   
            if (tel.length < 1) {
                //alert("      !");
                app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                    var infom = tpl({
                        itype: "warning", //  itype      class alert-xxxx
                        info: "      !"
                    }, {});
                    p.html(infom);
                    wait = 0;
                }, events.parent); //event    ,parent  
                return;
            } else {
                console.log(tel);
                _.post("api/admin/passwordrecover/tel", { //       
                    tel: tel
                }, function(r) {
                    console.info(r.successTag);
                    //alert("      !       !");
                    if (r.successTag == false) {
                        app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                            var infom = tpl({
                                itype: "warning", //  itype      class alert-xxxx
                                info: "       ,     !!"
                            }, {});
                            p.html(infom);
                            wait = 0;
                        }, events.parent); //event    ,parent  
                        return;
                    } else {
                        app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                            var infom = tpl({
                                itype: "success",
                                info: "      !       !!"
                            }, {});
                            p.html(infom);
                            var intk;

                            function showalert() {
                                if (wait == 0) {
                                    sender.html("       ");
                                    clearInterval(intk);
                                } else {
                                    sender.html("    (" + wait + ")");
                                    wait--;
                                }
                            }
                            intk = setInterval(showalert, 1000);
                        }, events.parent); //event    ,parent  
                        return;
                    }

                    //
                    //if(wait>0) return;

                    //  
                }, "json");
            }
            /* console.info(tel)
			   setTimeout  
                                if (wait > 0) return;
                                wait = 60;

                                function time(o) {
                                    if (wait == 0) {
                                        o.html("       ");
                                    } else {
                                        o.html("    (" + wait + ")");
                                        wait--;
                                        setTimeout(function() {
                                                time(o)
                                            },
                                            1000)
                                    }
                                }
                                time(sender);
                    */
            // var t=setTimeout("alert('5  !')",5000)//5       
            /* var phone = document.getElementsByName("tel");
            tel = phone.val();
            alert(tel);*/
            //window.location.href="http://www.baidu.com";
            /*
          var wait=60;
            function time(o) {
              
            }*/
        },
        TelOK: function(sender, arg) { //         
            var code = _('[data-item="code"]', events.parent).val(); //    [name="tel"] [data-item="telphone"]   
            var tel = _('[data-item="telphone"]', events.parent).val();
            console.info(code);
            console.info(tel);
            if (tel.length < 1) {
                if (code.length < 1) {
                    //alert("          !!");
                    app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                        var infom = tpl({
                            itype: "warning", //  itype      class alert-xxxx
                            info: "          !"
                        }, {});
                        p.html(infom);
                    }, events.parent); //event    ,parent  
                    return;
                } else {
                    //alert("      !");
                    app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                        var infom = tpl({
                            itype: "warning", //  itype      class alert-xxxx
                            info: "      !"
                        }, {});
                        p.html(infom);
                    }, events.parent); //event    ,parent  
                    return;
                };
            } else {
                if (code.length < 1) {
                    //alert("      !");
                    app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                        var infom = tpl({
                            itype: "warning", //  itype      class alert-xxxx
                            info: "      !"
                        }, {});
                        p.html(infom);
                    }, events.parent); //event    ,parent  
                    return;
                } else {
                    _.post("api/admin/passwordrecover/code", { //       
                        ValidateCode: code,
                        StuPhone: tel
                    }, function(r) {
                        console.log(r);
                        if (r.length > 0) {
                            //alert("    !");
                            //        
                            _('#myModal').modal('show');//     !
                            RefreshTool(3, tel, code);
                            // app.tpl("Admin->passwordrecover",function(){
                            //     data-target:"#myModal";
                            // }
                            /*app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                                var infom = tpl({
                                    itype: "success", //  itype      class alert-xxxx
                                    info: "    !"
                                }, {});
                                p.html(infom);

                            }, events.parent); //event    ,parent  
                            RefreshTool(3, tel);
                            return;*/

                        } else {
                            //alert("       !     !");
                            app.tpl("Admin->passwordrecover.alert", function(tpl, p) {
                                var infom = tpl({
                                    itype: "warning", //  itype      class alert-xxxx
                                    info: "       !     !!"
                                }, {});
                                p.html(infom);
                            }, events.parent); //event    ,parent  
                            return;
                        };
                    }, "json");
                };
            }
            //                 
            /*    var wait = 60;
             time:function (o){
                if (wait == 0) {
                    o.removeAttribute("disabled");            
                    o.value="       ";
                wait = 60;
             } else { // www.jbxue.com
                    o.setAttribute("disabled", true);
                    o.value="    (" + wait + ")";
                    wait--;
                        setTimeout(function() {
                            time(o)
                        },
                    1000)
                    }
                };*/

            //window.location.href="http://www.baidu.com";
            //RefreshTool(3);
        },
        btnOK: function(sender, arg) { //    
            var pwd1 = _('[data-item="password1"]', events.parent).val(); //    [name="tel"] [data-item="telphone"]   
            var pwd2 = _('[data-item="password2"]', events.parent).val();
            console.info(pwd1);
            console.info(pwd2);
            if (pwd1 == pwd2) {
                //alert("      !");
                _.post("api/admin/passwordrecover/save", { //       
                    pwd: pwd2,
                    tel: _("#Last").attr("tel"),
                    code: _("#Last").attr("code")
                }, function(r) {
                    console.info(r);
                    //alert("      !");
                    if (r.successTag == true) {
                        console.info(r.successTag);
                        app.tpl("Admin->passwordrecover.alert1", function(tpl, p) {
                            var infom = tpl({
                                itype: "success", //  itype      class alert-xxxx
                                info: "      !!"
                            }, {});
                            p.html(infom);
                        }, events.parent); //event    ,parent  
                        return;
                    } else {
                        console.info(r.successTag);
                        app.tpl("Admin->passwordrecover.alert1", function(tpl, p) {
                            var infom = tpl({
                                itype: "warning", //  itype      class alert-xxxx
                                info: "      !!!"
                            }, {});
                            p.html(infom);
                        }, events.parent); //event    ,parent  
                        return;
                    }

                })
            } else {
                //alert("       ,     !");
                app.tpl("Admin->passwordrecover.alert1", function(tpl, p) {
                    var infom = tpl({
                        itype: "warning", //  itype      class alert-xxxx
                        info: "       ,     !!!"
                    }, {});
                    p.html(infom);
                }, events.parent); //event    ,parent  
                return;
            }
            _("#Last").attr("tel")
            _("#Last").attr("code")
            //RefreshTool(1);
        }
    };
tplテンプレート
<div class="cpage container projects" id="${cid}">
	<div class="page-header-deai">
		<div class="container">
			<h1>
				<span class="icon icon-home" event="back" url="paper" style="cursor: pointer;margin-right: 10px"></span>
				    
			</h1>
		</div>
	</div>
	<hr class="hr-deai" />
	
	<div class="container">
		<div class="row">
			<div class="col-sm-8 col-sm-offset-2">
				<div  id="Setp1" style="float:left;font-size:16px;width:250px;height: 40px; background: url('Context/images/password/u6.png');">
					<img  style="left:0px;top:0px;width:26px;height:41px;"src="Context/images/password/u4.png"/>
					<span >1.      </span>
				</div>
				
				<div  id="Setp2" style="float:left;font-size:16px;width:250px;height: 40px; background: url('Context/images/password/u36.png');">
					<img  style="left:0px;top:0px;width:26px;height:41px;"src="Context/images/password/u4.png"/>
					<span >2.      </span>
				</div>
				
				<div  id="Setp3" style="float:left;font-size:16px;width:250px;height: 40px; background: url('Context/images/password/u2.png');">
					<img  style="left:0px;top:0px;width:26px;height:41px;"src="Context/images/password/u44.png"/>
					<span >3.     </span>
				</div>
			</div>
		</div>
		<div class="row" >
			<div class="col-sm-8 col-sm-offset-2" >
				<div style="height:330px; BORDER-LEFT: 1px solid gray ;BORDER-RIGHT: 1px solid gray;BORDER-BOTTOM: 1px solid gray;BORDER-TOP: 1px solid gray;">
					<br/>
					<div  id="First" class="row" style="display:true;"  >
						<div class="col-sm-6 ">
							<div class="thumbnail" >
								<img src="Context/images/paper/paper1.png" alt="  " style="width: 120px; margin-top: 20px;"/>
								<div  style="padding: 25px;">
									<button type="button" class="btn btn-default btn-lg" on="ByEmail">      </button>
								</div>
								<p><small>            </small></p>
							</div>
						</div>
						<div class="col-sm-6 ">
							<div class="thumbnail" >
								<img src="Context/images/paper/paper1.png" alt="  " style="width: 120px; margin-top: 20px;"/>
								<div  style="padding: 25px;">
									<button type="button" class="btn btn-default btn-lg" on="ByTel">      
									</button>
								</div>
								<p><small>             </small></p>
							</div>
						</div>
					</div>
					<div  id="Phone" style="text-align:center; display:none;" >
						
						<div class="btn-group "  style="width:350px;">
							<h4 style="float: left;">          
							</h4>
							<dl class="dl-horizontal" style="margin-top:50px;">
								<dt>   :</dt>
								<dd>
									<input type="text" class="form-control " name="tel"  placeholder="Tel" data-item="telphone" value="${Data.telphone}" />
								</dd>
								<br/>
								<dt>   :</dt>
								<dd>
									<input type="text" class="form-control"  data-item="code" value="${Data.code}"/>
									<u id="btn" style="cursor: pointer;" on="CodeOK" value="      ">      </u>
									<small style="color:gray;">60s     </small>
								</dd>
								<br/>
								<dt></dt>
								
								<dd>
									<button type="button" class="btn btn-default" style="padding-left:25px;padding-right:25px;" on="TelOK">   </button>
								</dd>
							</dl>
						</div>
						<div tpl="alert">
							{@if info}
							<tpl name="alert">
								<div class="alert alert-${itype} fade in" role="alert">${info}</div>
							</tpl>
							{@/if}
						</div>
					</div>
					<div  id="Email" style="text-align:center; display:none;" >
						<div class="btn-group "  style="width:350px;">
							<h4 style="float: left;">         </h4>
							<dl class="dl-horizontal" style="margin-top:50px;">
								<dt>    :</dt>
								<dd>
									<input type="email" class="form-control"  placeholder="Enter email"/>
								</dd>
								<br/>
								<dt></dt>
								<dd>
									<button type="button" class="btn btn-default" style="padding-left:25px;padding-right:25px;" on="EmailOK">    </button>
								</dd>
							</dl>
						</div>
					</div>
					<!--     -->
					<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" 
								data-dismiss="modal" aria-hidden="true">
								×
							</button>
							<h4 class="modal-title" id="myModalLabel">
								  
							</h4>
						</div>
						<div class="modal-body">
							    !
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-primary" 
							data-dismiss="modal">  
						</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal -->
		</div>
		<div  id="Last" style="text-align:center;display:none;" >
			<div class="btn-group "  style="width:350px;">
				<h4 style="float: left;">       </h4>
				<dl class="dl-horizontal" style="margin-top:50px;">
					<dt>   :</dt>
					<dd>
						<input type="password" class="form-control"  data-item="password1" placeholder="Password"/>
					</dd>
					<br/>
					<dt>    :</dt>
					<dd>
						<input type="password" class="form-control"  data-item="password2" placeholder="Password"/>
					</dd>
					<br/>
					<dt></dt>
					<dd>
						<button type="button" class="btn btn-default" style="padding-left:25px;padding-right:25px;" on="btnOK">   </button>
					</dd>
				</dl>
			</div>
			<div tpl="alert1">
				{@if info}
				<tpl name="alert1">
					<div class="alert alert-${itype} fade in" role="alert1">${info}</div>
				</tpl>
				{@/if}
			</div>
		</div>
	</div>
</div>
</div>
</div>
<br />
<div tpl="modal"></div>
</div>