Cutelyst  1.11.0
minimal.cpp
1 /*
2  * Copyright (C) 2013-2017 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #include "minimal.h"
19 
20 #include <QVariant>
21 
22 using namespace Cutelyst;
23 
25 {
26 
27 }
28 
29 StoreMinimal::~StoreMinimal()
30 {
31 
32 }
33 
35 {
36  m_users << user;
37 }
38 
39 
41 {
42  Q_UNUSED(c)
44  QString id = userInfo[QStringLiteral("id")];
45  if (id.isEmpty()) {
46  id = userInfo[QStringLiteral("username")];
47  }
48 
49  const auto users = m_users;
50  for (const AuthenticationUser &user : users) {
51  if (user.id() == id) {
52  ret = user;
53  break;
54  }
55  }
56 
57  return ret;
58 }
59 
61 {
62  return user.id();
63 }
64 
65 AuthenticationUser StoreMinimal::fromSession(Context *c, const QVariant &frozenUser)
66 {
67  return findUser(c, {
68  {QStringLiteral("id"), frozenUser.toString()}
69  });
70 }
71 
72 #include "moc_minimal.cpp"
QMap< QString, QString > ParamsMultiMap
void addUser(const AuthenticationUser &user)
Definition: minimal.cpp:34
virtual AuthenticationUser findUser(Context *c, const ParamsMultiMap &userInfo) final
Definition: minimal.cpp:40
virtual QVariant forSession(Context *c, const AuthenticationUser &user) final
Definition: minimal.cpp:60
The Cutelyst Context.
Definition: context.h:50
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
StoreMinimal(QObject *parent=nullptr)
Definition: minimal.cpp:24
virtual AuthenticationUser fromSession(Context *c, const QVariant &frozenUser) final
Definition: minimal.cpp:65