Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instagram Login/Registration #2562

Merged
merged 18 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
service-configuration@1.0.11
service-configuration
mdg:validated-method
[email protected]
[email protected]
Expand Down Expand Up @@ -93,3 +93,4 @@ johanbrook:publication-collector

# Custom Packages
abernix:[email protected]
bozhao:accounts-instagram
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
bozhao:[email protected]
[email protected]
[email protected]
[email protected]
Expand Down
1 change: 1 addition & 0 deletions client/modules/accounts/components/auth/loginButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class LoginButtons extends Component {

{this.props.currentView === "loginFormSignInView" &&
<span>
&nbsp;
<Translation defaultValue="Sign in with" i18nKey="accountsUI.signInWith" />
</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,21 @@ class MainDropdownContainer extends Component {

function getCurrentUser() {
const shopId = Reaction.getShopId();
const user = Accounts.user();
const user = Accounts.user() || {};

if (!shopId || typeof user !== "object") {
return null;
}


// shoppers should always be guests
const isGuest = Roles.userIsInRole(user, "guest", shopId);
// but if a user has never logged in then they are anonymous
const isAnonymous = Roles.userIsInRole(user, "anonymous", shopId);

return isGuest && !isAnonymous ? user : null;
const account = Collections.Accounts.findOne(user._id);

return isGuest && !isAnonymous ? account : null;
}

function getUserGravatar(currentUser, size) {
Expand Down
10 changes: 9 additions & 1 deletion client/modules/accounts/helpers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function capitalize(str) {
const providers = {
Facebook: {},
Google: {},
Twitter: {}
Twitter: {},
Instagram: {}
};

providers.Facebook.fields = function () {
Expand All @@ -34,6 +35,13 @@ providers.Twitter.fields = function () {
];
};

providers.Instagram.fields = function () {
return [
{ property: "clientId", label: "Client ID" },
{ property: "secret", label: "Client secret" }
];
};

export class ServiceConfigHelper {
availableServices() {
const services = Package["accounts-oauth"] ? Accounts.oauth.serviceNames() : [];
Expand Down
26 changes: 26 additions & 0 deletions client/modules/accounts/templates/profile/profile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { Roles } from "meteor/alanning:roles";
import { ReactiveVar } from "meteor/reactive-var";
import { Reaction } from "/client/api";
import { i18next } from "/client/api";
import * as Collections from "/lib/collections";

/**
Expand Down Expand Up @@ -58,6 +60,30 @@ Template.accountProfile.helpers({
return Collections.Accounts.findOne();
},

/**
* User's display name
* @return {String} display name
*/
displayName() {
const userId = Meteor.userId() || {};
const user = Collections.Accounts.findOne(userId);

if (user) {
if (user.name) {
return user.name;
} else if (user.username) {
return user.username;
} else if (user.profile && user.profile.name) {
return user.profile.name;
}
}

if (Roles.userIsInRole(user._id || user.userId, "account/profile",
Reaction.getShopId())) {
return i18next.t("accountsUI.guest", { defaultValue: "Guest" });
}
},

/**
* Returns the address book default view
* @return {String} "addressBookGrid" || "addressBookAdd"
Expand Down
1 change: 1 addition & 0 deletions private/data/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@
"facebook": "Facebook",
"google": "Google",
"github": "GitHub",
"instagram": "Instagram",
"meetup": "Meetup",
"ok": "Ok",
"twitter": "Twitter",
Expand Down
1 change: 1 addition & 0 deletions server/security/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ BrowserPolicy.content.allowOriginForAll("*.facebook.com");
BrowserPolicy.content.allowOriginForAll("*.fbcdn.net");
BrowserPolicy.content.allowOriginForAll("connect.facebook.net");
BrowserPolicy.content.allowOriginForAll("*.googleusercontent.com");
BrowserPolicy.content.allowOriginForAll("*.cdninstagram.com");

BrowserPolicy.content.allowImageOrigin("fbcdn-profile-a.akamaihd.net");
BrowserPolicy.content.allowImageOrigin("secure.gravatar.com");
Expand Down