summaryrefslogtreecommitdiffstats
path: root/webapp/actions/oauth_actions.jsx
blob: 07b4c290803b70b34c3551a86f29df642235a6b3 (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
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import Client from 'client/web_client.jsx';
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
import Constants from 'utils/constants.jsx';

const ActionTypes = Constants.ActionTypes;

export function listOAuthApps(userId, onSuccess, onError) {
    Client.listOAuthApps(
        (data) => {
            AppDispatcher.handleServerAction({
                type: ActionTypes.RECEIVED_OAUTHAPPS,
                userId,
                oauthApps: data
            });

            if (onSuccess) {
                onSuccess(data);
            }
        },
        onError
    );
}

export function deleteOAuthApp(id, userId, onSuccess, onError) {
    Client.deleteOAuthApp(
        id,
        () => {
            AppDispatcher.handleServerAction({
                type: ActionTypes.REMOVED_OAUTHAPP,
                userId,
                id
            });

            if (onSuccess) {
                onSuccess();
            }
        },
        onError
    );
}

export function registerOAuthApp(app, onSuccess, onError) {
    Client.registerOAuthApp(
        app,
        (data) => {
            AppDispatcher.handleServerAction({
                type: ActionTypes.RECEIVED_OAUTHAPP,
                oauthApp: data
            });

            if (onSuccess) {
                onSuccess(data);
            }
        },
        onError
    );
}