aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/login.h
blob: 31d4dc64cbd0ea918b32b9a1b02625f09cc8dbf6 (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "jobs/basejob.h"

#include "converters.h"
#include <QtCore/QVector>

namespace QMatrixClient
{
    // Operations

    /// Get the supported login types to authenticate users
    /// 
    /// Gets the homeserver's supported login types to authenticate users. Clients
    /// should pick one of these and supply it as the ``type`` when logging in.
    class GetLoginFlowsJob : public BaseJob
    {
        public:
            // Inner data structures

            /// Gets the homeserver's supported login types to authenticate users. Clients
            /// should pick one of these and supply it as the ``type`` when logging in.
            struct LoginFlow
            {
        /// The login type. This is supplied as the ``type`` when
        /// logging in.
                QString type;
            };

            // Construction/destruction

            explicit GetLoginFlowsJob();

            /*! Construct a URL without creating a full-fledged job object
             *
             * This function can be used when a URL for
             * GetLoginFlowsJob is necessary but the job
             * itself isn't.
             */
            static QUrl makeRequestUrl(QUrl baseUrl);

            ~GetLoginFlowsJob() override;

            // Result properties

            /// The homeserver's supported login types
            const QVector<LoginFlow>& flows() const;

        protected:
            Status parseJson(const QJsonDocument& data) override;

        private:
            class Private;
            QScopedPointer<Private> d;
    };

    /// Authenticates the user.
    /// 
    /// Authenticates the user, and issues an access token they can
    /// use to authorize themself in subsequent requests.
    /// 
    /// If the client does not supply a ``device_id``, the server must
    /// auto-generate one.
    /// 
    /// The returned access token must be associated with the ``device_id``
    /// supplied by the client or generated by the server. The server may
    /// invalidate any access token previously associated with that device. See
    /// `Relationship between access tokens and devices`_.
    class LoginJob : public BaseJob
    {
        public:
            /*! Authenticates the user.
             * \param type 
             *   The login type being used.
             * \param user 
             *   The fully qualified user ID or just local part of the user ID, to log in.
             * \param medium 
             *   When logging in using a third party identifier, the medium of the identifier. Must be 'email'.
             * \param address 
             *   Third party identifier for the user.
             * \param password 
             *   Required when ``type`` is ``m.login.password``. The user's
             *   password.
             * \param token 
             *   Required when ``type`` is ``m.login.token``. Part of `Token-based`_ login.
             * \param deviceId 
             *   ID of the client device. If this does not correspond to a
             *   known client device, a new device will be created. The server
             *   will auto-generate a device_id if this is not specified.
             * \param initialDeviceDisplayName 
             *   A display name to assign to the newly-created device. Ignored
             *   if ``device_id`` corresponds to a known device.
             */
            explicit LoginJob(const QString& type, const QString& user = {}, const QString& medium = {}, const QString& address = {}, const QString& password = {}, const QString& token = {}, const QString& deviceId = {}, const QString& initialDeviceDisplayName = {});
            ~LoginJob() override;

            // Result properties

            /// The fully-qualified Matrix ID that has been registered.
            const QString& userId() const;
            /// An access token for the account.
            /// This access token can then be used to authorize other requests.
            const QString& accessToken() const;
            /// The server_name of the homeserver on which the account has
            /// been registered.
            /// 
            /// **Deprecated**. Clients should extract the server_name from
            /// ``user_id`` (by splitting at the first colon) if they require
            /// it. Note also that ``homeserver`` is not spelt this way.
            const QString& homeServer() const;
            /// ID of the logged-in device. Will be the same as the
            /// corresponding parameter in the request, if one was specified.
            const QString& deviceId() const;

        protected:
            Status parseJson(const QJsonDocument& data) override;

        private:
            class Private;
            QScopedPointer<Private> d;
    };
} // namespace QMatrixClient