Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
96 lines (87 loc) · 1.75 KB

File metadata and controls

96 lines (87 loc) · 1.75 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import * as axios from 'axios';
import config from 'config';
/**
* FB_LOGIN
* @type {string}
*/
export const FB_LOGIN = 'USER_FB_LOGIN';
/**
* _fbLoginInitial
* @param initial
* @private
*/
const _fbLoginInitial = initial => ({ type: FB_LOGIN, initial });
/**
* fbLogin
* Performs Facebook login, and on success posts return data to API
* Redux Action
* Reference: http://redux.js.org/docs/basics/Actions.html
* @param response {Object}
* @returns {Function}
*/
export function fbLogin(response) {
const token = response.authResponse.accessToken;
const userID = response.authResponse.userID;
return dispatch => {
axios
.post(`${config.api.baseUrl}/users`, {
token: token,
fb_user_id: userID,
})
.then(function(res) {
localStorage.setItem('jwt', res.data.jwt);
dispatch(_fbLoginInitial(res.data));
})
.catch(function(res) {
window.location.reload();
dispatch(_fbLoginInitial(res.data));
});
};
}
/**
* LOGOUT
* @type {string}
*/
export const LOGOUT = 'USER_LOGOUT';
/**
* _logoutRequest
* @private
*/
export const _logoutRequest = () => ({ type: LOGOUT });
/**
* _logoutResponse
* @param response
* @private
*/
export const _logoutResponse = response => ({ type: LOGOUT, response });
/**
* logout
* Performs Facebook logout for a given user
* Redux Action
* Reference: http://redux.js.org/docs/basics/Actions.html
* @returns {Function}
*/
export function logout() {
return dispatch => {
dispatch(_logoutRequest());
FB.logout(response => {
dispatch(_logoutResponse(response));
});
};
}
/**
* FOLLOW
* @type {string}
*/
export const FOLLOW = 'USER_FOLLOW';
/**
* follow
* @param user
* @returns {{type: string, user: *}}
*/
export function follow(user) {
return {
type: FOLLOW,
user,
};
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.