-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathqtfirebaseauth.h
executable file
·103 lines (87 loc) · 2.43 KB
/
qtfirebaseauth.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef QTFIREBASE_AUTH_H
#define QTFIREBASE_AUTH_H
#include "qtfirebaseservice.h"
#include "firebase/auth.h"
#ifdef QTFIREBASE_BUILD_AUTH
#include "src/qtfirebase.h"
#if defined(qFirebaseAuth)
#undef qFirebaseAuth
#endif
#define qFirebaseAuth (static_cast<QtFirebaseAuth *>(QtFirebaseAuth::instance()))
class QtFirebaseAuth : public QtFirebaseService
{
Q_OBJECT
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
Q_PROPERTY(bool signedIn READ signedIn NOTIFY signedInChanged)
public:
static QtFirebaseAuth *instance()
{
if(self == nullptr)
{
self = new QtFirebaseAuth(0);
qDebug() << self << "::instance" << "singleton";
}
return self;
}
enum Error
{
ErrorNone = firebase::auth::kAuthErrorNone,
ErrorUnimplemented = firebase::auth::kAuthErrorUnimplemented,
ErrorFailure = firebase::auth::kAuthErrorFailure
};
Q_ENUM(Error)
enum Action
{
ActionRegister,
ActionSignIn,
ActionSignOut,
ActionDeleteUser
};
Q_ENUM(Action)
public slots:
//Control
void registerUser(const QString& email, const QString& pass);
void signIn(const QString& email, const QString& pass);
void signOut();
void sendPasswordResetEmail(const QString& email);
void deleteUser();
// social sign in
void googleSignIn();
//void facebookSignIn();
//void twitterSignIn();
//Status
bool signedIn() const;
bool running() const;
int errorId() const;
QString errorMsg() const;
//Data
QString email() const;
QString displayName() const;
bool emailVerified() const;
QString photoUrl() const;
QString uid() const;
signals:
void signedInChanged();
void runningChanged();
void completed(bool success, int actionId);
void passwordResetEmailSent();
protected:
explicit QtFirebaseAuth(QObject *parent = 0);
private:
void clearError();
void setComplete(bool complete);
void setSignIn(bool value);
void setError(int errId, const QString& errMsg = QString());
void init() override;
void onFutureEvent(QString eventId, firebase::FutureBase future) override;
static QtFirebaseAuth *self;
firebase::auth::Auth* m_auth;
bool m_complete;
bool m_signedIn;
int m_errId;
QString m_errMsg;
int m_action;
Q_DISABLE_COPY(QtFirebaseAuth)
};
#endif //QTFIREBASE_BUILD_AUTH
#endif // QTFIREBASE_AUTH_H