-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasswordManager.h
More file actions
33 lines (28 loc) · 847 Bytes
/
passwordManager.h
File metadata and controls
33 lines (28 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef PWD_MANAGER_H
#define PWD_MANAGER_H
#include<unordered_map>
#include<string>
#include "fileIO.h"
#include<ArduinoJson.h>
#include <ArduinoIoTCloud.h>
#include "ntp.h"
class PasswordManager
{
private:
std::unordered_map<std::string, std::string> userPwdMap;
std::string pwdFileName;
std::string logFileName;
std::string latestLoginMsg; // JSON format {"userName": "xxx", "time": "xxx"}
void updatePwdFile();
void login(const char* userName);
long timeOffset;
public:
PasswordManager();
PasswordManager(const long timeOffset);
void init(const char* pwdFileName, const char* logFileName);
bool verifyPassword(const char* pwd);
bool changePassword(const char* userName, const char* newPwd);
std::string getLatestLoginMsg();
std::string getPassword(const char* userName);
};
#endif