summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-14 08:43:49 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-14 12:38:16 -0400
commitb704e9489b21b3bec17f5c8b573a1724781ee6f7 (patch)
tree002f9fb35ce932800160bc45d91a50804bbb6594 /web/react/utils
parente27db2ed63fd3c9c686c049a9b9049a907985ecc (diff)
downloadchat-b704e9489b21b3bec17f5c8b573a1724781ee6f7.tar.gz
chat-b704e9489b21b3bec17f5c8b573a1724781ee6f7.tar.bz2
chat-b704e9489b21b3bec17f5c8b573a1724781ee6f7.zip
added google sign-in functionality to the client, with minor model modifications
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/async_client.jsx14
-rw-r--r--web/react/utils/client.jsx15
-rw-r--r--web/react/utils/constants.jsx2
3 files changed, 21 insertions, 10 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 0b87bbd7b..09710ddf0 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -390,15 +390,15 @@ module.exports.getPosts = function(force, id, maxPosts) {
}
}
-function getMe() {
- if (isCallInProgress('getMe')) {
+function getMeSynchronous() {
+ if (isCallInProgress('getMeSynchronous')) {
return;
}
- callTracker.getMe = utils.getTimestamp();
- client.getMe(
+ callTracker.getMeSynchronous = utils.getTimestamp();
+ client.getMeSynchronous(
function(data, textStatus, xhr) {
- callTracker.getMe = 0;
+ callTracker.getMeSynchronous = 0;
if (xhr.status === 304 || !data) return;
@@ -409,11 +409,11 @@ function getMe() {
},
function(err) {
callTracker.getMe = 0;
- dispatchError(err, 'getMe');
+ dispatchError(err, 'getMeSynchronous');
}
);
}
-module.exports.getMe = getMe;
+module.exports.getMeSynchronous = getMeSynchronous;
module.exports.getStatuses = function() {
if (isCallInProgress('getStatuses')) return;
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 5aab80d01..ce044457a 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -279,24 +279,33 @@ module.exports.getAudits = function(userId, success, error) {
});
};
-module.exports.getMe = function(success, error) {
+module.exports.getMeSynchronous = function(success, error) {
+ var currentUser = null;
$.ajax({
+ async: false,
url: "/api/v1/users/me",
dataType: 'json',
contentType: 'application/json',
type: 'GET',
- success: success,
+ success: function gotUser(data, textStatus, xhr) {
+ currentUser = data;
+ if (success) {
+ success(data, textStatus, xhr);
+ }
+ },
error: function(xhr, status, err) {
var ieChecker = window.navigator.userAgent; // This and the condition below is used to check specifically for browsers IE10 & 11 to suppress a 200 'OK' error from appearing on login
if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) {
if (error) {
- e = handleError("getMe", xhr, status, err);
+ e = handleError('getMeSynchronous', xhr, status, err);
error(e);
};
};
}
});
+
+ return currentUser;
};
module.exports.inviteMembers = function(data, success, error) {
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index 508de9185..1fe0faccf 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -58,6 +58,8 @@ module.exports = {
THUMBNAIL_HEIGHT: 100,
DEFAULT_CHANNEL: 'town-square',
OFFTOPIC_CHANNEL: 'off-topic',
+ GITLAB_SERVICE: 'gitlab',
+ GOOGLE_SERVICE: 'google',
POST_CHUNK_SIZE: 60,
MAX_POST_CHUNKS: 3,
RESERVED_TEAM_NAMES: [