cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
authenticationuser.h
1/*
2 * SPDX-FileCopyrightText: (C) 2013-2022 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef AUTHENTICATIONUSER_H
6#define AUTHENTICATIONUSER_H
7
8#include <Cutelyst/cutelyst_global.h>
9#include <Cutelyst/paramsmultimap.h>
10#include <Cutelyst/plugin.h>
11
12#include <QDataStream>
13#include <QVariantMap>
14
15namespace Cutelyst {
16
17class AuthenticationRealm;
18
29class CUTELYST_PLUGIN_AUTHENTICATION_EXPORT AuthenticationUser
30{
31 Q_GADGET
32public:
37
42
46 virtual ~AuthenticationUser();
47
51 [[nodiscard]] QVariant id() const;
52
56 void setId(const QVariant &id);
57
61 [[nodiscard]] bool isNull() const;
62
66 [[nodiscard]] QString authRealm();
67
71 void setAuthRealm(const QString &authRealm);
72
76 [[nodiscard]] inline QVariantMap data() const;
77
81 inline void setData(const QVariantMap &data);
82
89 inline void insert(const QString &key, const QVariant &value);
90
97 [[nodiscard]] inline QVariant value(const QString &key,
98 const QVariant &defaultValue = QVariant()) const;
99
100 inline operator QVariant() const { return QVariant::fromValue(m_data); }
101
102protected:
103 QVariantMap m_data;
104};
105
106QVariantMap AuthenticationUser::data() const
107{
108 return m_data;
109}
110
111void AuthenticationUser::setData(const QVariantMap &data)
112{
113 m_data = data;
114}
115
116void AuthenticationUser::insert(const QString &key, const QVariant &value)
117{
118 m_data.insert(key, value);
119}
120
121QVariant AuthenticationUser::value(const QString &key, const QVariant &defaultValue) const
122{
123 return m_data.value(key, defaultValue);
124}
125
126} // namespace Cutelyst
127
128Q_DECLARE_METATYPE(Cutelyst::AuthenticationUser)
129QDataStream &operator<<(QDataStream &out, const Cutelyst::AuthenticationUser &myObj);
131
132QDebug CUTELYST_PLUGIN_AUTHENTICATION_EXPORT operator<<(QDebug dbg,
133 const Cutelyst::AuthenticationUser &user);
134
135#endif // AUTHENTICATIONUSER_H
Container for user data retrieved from an AuthenticationStore.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setData(const QVariantMap &data)
void insert(const QString &key, const QVariant &value)
The Cutelyst namespace holds all public Cutelyst API.
QVariant fromValue(const T &value)