mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
fix twitter login; throw different error when document is not found
This commit is contained in:
parent
1749d4dcd7
commit
ac2aa28e6c
6 changed files with 24 additions and 8 deletions
|
@ -115,6 +115,7 @@ const withList = (options) => {
|
|||
results = props.data[listResolverName],
|
||||
totalCount = props.data[totalResolverName],
|
||||
networkStatus = props.data.networkStatus,
|
||||
loading = props.data.loading,
|
||||
error = props.data.error;
|
||||
|
||||
if (error) {
|
||||
|
@ -124,7 +125,7 @@ const withList = (options) => {
|
|||
return {
|
||||
// see https://github.com/apollostack/apollo-client/blob/master/src/queries/store.ts#L28-L36
|
||||
// note: loading will propably change soon https://github.com/apollostack/apollo-client/issues/831
|
||||
loading: networkStatus === 1, // networkStatus = 1 <=> the graphql container is loading
|
||||
loading,
|
||||
results,
|
||||
totalCount,
|
||||
refetch,
|
||||
|
|
|
@ -11,6 +11,7 @@ addStrings('en', {
|
|||
"accounts.error_user_not_found": "User not found",
|
||||
"accounts.error_username_already_exists": "Username already exists",
|
||||
"accounts.enter_username_or_email": "Enter username or email",
|
||||
"accounts.error_internal_server_error": "Internal server error",
|
||||
"accounts.username_or_email": "Username or email",
|
||||
"accounts.enter_username": "Enter username",
|
||||
"accounts.username": "Username",
|
||||
|
@ -191,6 +192,7 @@ addStrings('en', {
|
|||
"app.or": "Or",
|
||||
"app.noPermission": "Sorry, you do not have the permission to do this at this time.",
|
||||
"app.operation_not_allowed": 'Sorry, you don\'t have the rights to perform the operation "{value}"',
|
||||
"app.document_not_found": "Document not found (id: {value})",
|
||||
"app.disallowed_property_detected": "Disallowed property detected: {value}",
|
||||
"app.something_bad_happened": "Something bad happened...",
|
||||
"app.embedly_not_authorized": "Invalid Embedly API key provided in the settings file. To find your key, log into https://app.embed.ly -> API",
|
||||
|
|
|
@ -447,6 +447,14 @@ Utils.defineName = (o, name) => {
|
|||
return o;
|
||||
};
|
||||
|
||||
Utils.performCheck = (operation, user, checkedObject, context) => {
|
||||
if (!operation.check(user, checkedObject, context)) throw new Error(Utils.encodeIntlError({id: `app.operation_not_allowed`, value: operation.name}));
|
||||
Utils.performCheck = (operation, user, checkedObject, context, documentId) => {
|
||||
|
||||
if (!checkedObject) {
|
||||
throw new Error(Utils.encodeIntlError({id: `app.document_not_found`, value: documentId}))
|
||||
}
|
||||
|
||||
if (!operation.check(user, checkedObject, context)) {
|
||||
throw new Error(Utils.encodeIntlError({id: `app.operation_not_allowed`, value: operation.name}));
|
||||
}
|
||||
|
||||
}
|
|
@ -62,7 +62,6 @@ const resolvers = {
|
|||
name: 'postsSingle',
|
||||
|
||||
check(user, document, collection) {
|
||||
if (!document) return false;
|
||||
const status = _.findWhere(collection.statuses, {value: document.status});
|
||||
return Users.owns(user, document) ? Users.canDo(user, `posts.view.${status.label}.own`) : Users.canDo(user, `posts.view.${status.label}.all`);
|
||||
},
|
||||
|
@ -72,7 +71,7 @@ const resolvers = {
|
|||
// don't use Dataloader if post is selected by slug
|
||||
const post = documentId ? await Posts.loader.load(documentId) : Posts.findOne({slug});
|
||||
|
||||
Utils.performCheck(this, currentUser, post, Posts);
|
||||
Utils.performCheck(this, currentUser, post, Posts, documentId);
|
||||
|
||||
return Users.restrictViewableFields(currentUser, Posts, post);
|
||||
},
|
||||
|
|
|
@ -26,6 +26,11 @@ const schema = {
|
|||
optional: true,
|
||||
viewableBy: ['guests'],
|
||||
insertableBy: ['guests'],
|
||||
onInsert: user => {
|
||||
if (user.services.twitter && user.services.twitter.screenName) {
|
||||
return user.services.twitter.screenName;
|
||||
}
|
||||
}
|
||||
},
|
||||
emails: {
|
||||
type: Array,
|
||||
|
@ -112,10 +117,10 @@ const schema = {
|
|||
return user.profile.username;
|
||||
} else if (user.profile && user.profile.name) {
|
||||
return user.profile.name;
|
||||
} else if (user.services.twitter && user.services.twitter.screenName) {
|
||||
return user.services.twitter.screenName;
|
||||
} else if (user.services.linkedin && user.services.linkedin.firstName) {
|
||||
return user.services.linkedin.firstName + " " + user.services.linkedin.lastName;
|
||||
} else {
|
||||
return user.username;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Users from '../collection.js';
|
||||
import { runCallbacks, runCallbacksAsync } from 'meteor/vulcan:lib'; // import from vulcan:lib because vulcan:core isn't loaded yet
|
||||
import { runCallbacks, runCallbacksAsync, Utils } from 'meteor/vulcan:lib'; // import from vulcan:lib because vulcan:core isn't loaded yet
|
||||
|
||||
function onCreateUserCallback (options, user) {
|
||||
|
||||
|
@ -7,6 +7,7 @@ function onCreateUserCallback (options, user) {
|
|||
|
||||
delete options.password; // we don't need to store the password digest
|
||||
delete options.username; // username is already in user object
|
||||
delete options.profile; // we don't use profile
|
||||
|
||||
// validate options since they can't be trusted
|
||||
Users.simpleSchema().validate(options);
|
||||
|
|
Loading…
Add table
Reference in a new issue