root/http/token.hh

Revision 868b365c127bbf4f0b52f22da03e32a94a4f6653, 2.1 KB (checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 3 years ago)

Update the project blurb

Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>

  • Property mode set to 100644
Line 
1/*  This file is part of Alue, the multiprotocol Internet discussion daemon
2
3    Copyright © 2009 Antti-Juhani Kaijanaho
4
5    Alue is free software: you can redistribute it and/or modify it
6    under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    Alue is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with Alue.  If not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20#ifndef GUARD_HTTP_TOKEN_HH
21#define GUARD_HTTP_TOKEN_HH
22
23#include <boost/date_time/posix_time/posix_time.hpp>
24#include <boost/noncopyable.hpp>
25#include <boost/shared_ptr.hpp>
26
27namespace db { class user; }
28
29namespace http
30{
31        class token : private boost::noncopyable
32        {
33        public:
34                const enum kinds { PASSWD, NEWUSER } kind;
35
36                token(boost::shared_ptr<db::user> user,
37                      kinds k)
38                        : kind(k)
39                        , user(user)
40                        , expires_at(boost::posix_time::second_clock::
41                                     universal_time() +
42                                     boost::posix_time::hours(2))
43                        {}
44 
45                boost::shared_ptr<db::user> get_user() const {
46                        if (boost::posix_time::second_clock::universal_time()
47                            >= expires_at)
48                                return boost::shared_ptr<db::user>();
49                        return user;
50                }
51
52                boost::posix_time::ptime expiration_time() const {
53                        return expires_at;
54                }
55        private:
56                boost::shared_ptr<db::user> user;
57                boost::posix_time::ptime expires_at;
58        };
59}
60
61#endif /* GUARD_HTTP_TOKEN_HH */
Note: See TracBrowser for help on using the browser.