Commit 8e654b26 authored by PranjalKushwaha's avatar PranjalKushwaha

feat: Login API

parents
#include <iostream>
#include "utils.h"
int main()
{
string name,password;
cin >> name >> password;
if(login(name,password))
{
cout << "Success!"<< endl;
}
else
{
cout << "Login Failed :(" << endl;
}
}
\ No newline at end of file
#ifndef PASSWORDS_H
#define PASWSWORDS_H
#include<map>
#include<string>
using namespace std;
map<string, string> passwords {
{"Tinsmorem","Iltil"},
{"Ulyglet","Snurgrurg"},
{"Lafibnom","Diamdioc"},
{"Thenbovir","Oudrarrouz"},
{"Gallnip","Haulmi"},
{"Froolvess","Holdiz"},
{"Smameknuc","Hinnyual"},
{"Smedekmet","Traolbubrorg"},
{"Cebbnec","Khishohi"},
{"Klolyddwac","Maennius"},
{"Blivylnas","Jolmuulmohr"},
{"Glyhamdas","Drustiel"},
{"Hillnar","Nanruddiarth"},
{"Phieddlu","Zussial"},
{"Fnamdyn","Laszo"},
{"Fladnivith","Nathentoih"},
{"Phelnyll","Phorughoelle"},
{"Snallbam","Skilzeda"},
{"Fensmyl","Vrakniarth"},
{"Pibkecim","Jerpuldo"}
};
//Return true only if the person is present in the database
bool find_user(string name){
if(passwords.find(name) != passwords.end()) return true;
else return false;
}
//Returns the password for a particular person
string get_password(string name){
return passwords[name];
}
#endif
#include "passwords.h"
bool login(string name, string password)
{
if(find_user(name))
{
string s = get_password(name);
if(s==password)
{
return true;
}
else{
return false;
}
}
else
return false;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment