MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / OnOKPress

Function OnOKPress

System/Login/main.cpp:29–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27std::map<std::string, User> users;
28
29void OnOKPress(__attribute__((unused)) Lemon::GUI::Button* b){
30 if(users.find(usernameBox->contents.front()) != users.end()){
31 User& user = users.at(usernameBox->contents.front());
32
33 SHA256 passwordHash;
34 passwordHash.Update(passwordBox->contents.front().data(), passwordBox->contents.front().length());
35
36 if(user.hash.compare(passwordHash.GetHash())){
37 char buf[128];
38 printf("Actual hash: %s, inserted hash: %s\n", user.hash.c_str(), passwordHash.GetHash().c_str());
39 snprintf(buf, 128, "Incorrect password for '%s'!", usernameBox->contents.front().c_str());
40 Lemon::GUI::DisplayMessageBox("Incorrect Password", buf);
41 return;
42 }
43
44 setuid(user.uid);
45 setgid(user.gid);
46
47 char* const args[] = {const_cast<char*>("/system/bin/shell.lef")};
48 lemon_spawn(*args, 1, args, 0);
49
50 delete window;
51
52 exit(0);
53 } else {
54 char buf[128];
55 snprintf(buf, 128, "Unknown user '%s'", usernameBox->contents.front().c_str());
56 Lemon::GUI::DisplayMessageBox("Invalid Username", buf);
57 return;
58 }
59}
60
61int main(int argc, char** argv){
62 Lemon::JSONParser cfgParser = Lemon::JSONParser("/system/lemon/users.json");

Callers

nothing calls this directly

Calls 7

DisplayMessageBoxFunction · 0.85
lemon_spawnFunction · 0.85
dataMethod · 0.80
lengthMethod · 0.80
GetHashMethod · 0.80
endMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected