Esempio n. 1
0
bool simpleAuth::changePasswordHandler(
                      Session &session,ESP8266WebServer *s,String &p){
  DynamicJsonBuffer jsonBuffer;
  JsonObject& r = jsonBuffer.createObject();
  r["exitcode"]="0";
  r["exitmsg"]="OK password changed";
  r["time"]=millis();
  String callback=s->arg("callback");

  if (s->arg("newpassword")==s->arg("newpassword2")){
     String oldpass(s->arg("oldpassword"));
     String newpass(s->arg("newpassword"));
     bool chpass=this->changeUserPassword(session.user,oldpass,newpass);
     if (!chpass){
        r["exitcode"]="20";
        r["exitmsg"]="password change failed";
     }
  }
  else{
     r["exitcode"]="10";
     r["exitmsg"]="new password repeat is not identical";
  }


  String dstr;
  r.prettyPrintTo(dstr);
  s->send(200, "application/javascript",callback+"("+dstr+");");
  return(true);
}
Esempio n. 2
0
int LuaLobby::ChangePass(lua_State *L)
{
	LuaLobby* lob = toLuaLobby(L, 1);
	std::string oldpass(luaL_checkstring(L, 2));
	std::string newpass(luaL_checkstring(L, 3));
	lob->ChangePass(oldpass, newpass);
	return 0;
}
Esempio n. 3
0
int simpleAuth::command(Session *session,Print *cli,char **args,int argn){
   if (!strcmp(args[0],"passwd") && argn==4){
      String username(args[1]);
      String oldpass(args[2]);
      String newpass(args[3]);
      bool chpass=this->changeUserPassword(username,oldpass,newpass);
      if (chpass){
         return(CMD_OK);
      }
      return(CMD_SYNTAX);
   }
   else if (!strcmp(args[0],"help") &&
       ( (argn==1) ||
         (argn==2 && !strcmp(args[1],"auth")))){
      cli->printf("\n%s:\n",PackName.c_str());
      cli->printf("passwd <USER> <OLDPASS> <NEWPASS>\n",PackName.c_str());
      cli->printf("    Sets the password of an user.\n");
      cli->printf("\n","");
      return(CMD_PART);
   }
   return(0);
}