From e3e76758b7ca18a8f10feca937092a6429f33160 Mon Sep 17 00:00:00 2001 From: Oswald Auguste de Bruin Date: Mon, 9 Dec 2013 11:08:00 +0100 Subject: [PATCH] Added code for initial login create through LSP --- src/controller/controller.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 452edcbc..f8fdfd81 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -86,6 +86,18 @@ namespace Controller { conn.Authorized = false; Response["authorize"]["status"] = "CHALL"; Response["authorize"]["challenge"] = Challenge; + //the following is used to add the first account through the LSP + if (!Storage["account"]){ + Response["authorize"]["status"] = "NOACC"; + if (Request["authorize"]["new_username"] && Request["authorize"]["new_password"]){ + //create account + Controller::Log("CONF", "Created account " + Request["authorize"]["new_username"].asString() + " through API"); + Controller::Storage["account"][Request["authorize"]["new_username"].asString()]["password"] = Secure::md5(Request["authorize"]["new_password"].asString()); + Response["authorize"]["status"] = "ACC_MADE"; + }else{ + Response["authorize"].removeMember("challenge"); + } + } return; }