Asteroid Oauth loginServiceConfiguration: 'google' of undefined - javascript

I've followed the 'naive' implementation in the project README: https://github.com/mondora/asteroid-oauth-mixin
The only difference in my code from the example is changing the arrow function to a traditional for the usage of this.
asteroid.ddp.on("added", ({collection, id, fields}: { collection: string; fields: {}, id: string }) => {
if (collection === "meteor_accounts_loginServiceConfiguration") {
asteroid.loginServiceConfiguration = {
...asteroid.loginServiceConfiguration,
[id]: {
_id: id,
...fields
}
};
}
});
});
asteroid.getServiceConfig = function(providerName: string) { // ts file
return this.loginServiceConfiguration[providerName];
}
When I do asteroid.loginWith('google')
index.ts:50 Uncaught TypeError: Cannot read property 'google' of undefined
On the meteor backend I also installed meteor add accounts-base accounts-google because I assume this is a dependency.
What am I missing? Thanks!
I've tried adding DDP.loginServiceConfiguration = {} before the snippet above which resolves the error but creates a new error.
asteroid-oauth-mixin.js:787 Uncaught TypeError: Cannot read property 'clientId' of undefined
at getOauthClientId (asteroid-oauth-mixin.js:787)
at Object.getOptions (asteroid-oauth-mixin.js:720)
at Asteroid.loginWith (asteroid-oauth-mixin.js:104)
at LoginForm../src/routes/accounts/auth/LoginForm.tsx.LoginForm.handleLoginWithGoogle (
Also when I run meteor mongo should db.meteor_accounts_loginServiceConfiguration.find().count() be 0 ?

I needed to meteor add service-configuration and setup my configure-accounts.js and create a google clientId for the application.
This gets me to the point where I have a popup and can choose which user to auth with. Then I receive a new error about target origin mismatch, but I'm going to close this question as resolved.

Related

Exception when checking if an issue field becomes "In Progress" with workflow

My issue fields have a State and an option called In Progress
So I wrote a Youtrack Workflow that launches a http post to my discord channel when an issue becomes "In Progress".
Here is the JavaScript code for that:
var entities = require('#jetbrains/youtrack-scripting-api/entities');
var http = require('#jetbrains/youtrack-scripting-api/http');
exports.rule = entities.Issue.onChange({
// TODO: give the rule a human-readable title
title: 'Open-discord-channel',
guard: function(ctx) {
return ctx.issue.fields.becomes(ctx.State, ctx.State.InProgress);
},
action: function(ctx) {
var issue = ctx.issue;
var connection = new http.Connection('https://discordapp.com');
connection.addHeader('Content-Type', 'application/json');
var response = connection.postSync('/api/webhooks/123/1DJucC8-vdZR-xxx', [], issue.description);
if (response && response.code === 200) {
issue.addComment(response.response);
}
// TODO: specify what to do when a change is applied to an issue
},
requirements: {
// TODO: add requirements
}
});
When activating this workflow this exception gets thrown:
TypeError: Cannot read property "InProgress" from undefined (open-discord-channel/open-discord-channel#16)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4198)
org.mozilla.javascript.gen.open_discord_channel_open_discord_channel_2052._c_anonymous_1(open-discord-channel/open-discord-channel:16)
It tells me Cannot read property "InProgress" but in fact return ctx.issue.fields.becomes(ctx.State, ctx.State.InProgress); the value InProgress was suggested by the embedded Youtrack Workflow editor.
Can anybody tell me how I can access the real "In Progress" value to make this code running?
EDIT
tried this
return ctx.issue.fields.becomes(ctx.State.name, "In Progress");
Still gave me an exception
Processing issue COOPR-85:
TypeError: Cannot read property "name" from undefined (open-discord-channel/open-discord-channel#16)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4198)
org.mozilla.javascript.gen.open_discord_channel_open_discord_channel_2076._c_anonymous_1(open-discord-channel/open-discord-channel:16)
If you want to use the ctx.issue.fields.becomes(ctx.State, ctx.State.InProgress) syntax, add a definition for the 'In Progress' state to the requirements section:
requirements: {
State: {
type: entities.State.fieldType,
InProgress: {
name: 'In Progress'
}
}
}
Alternatively, to avoid the Cannot read property "name" from undefined error, check the State field for null values:
return ctx.issue.fields.State && ctx.issue.fields.becomes(ctx.State.name, "In Progress");
I hope it will be helpful.

SAP Fiori Launchpad Custom App Error: Cannot instantiate object: "new" is missing

After trying to start our custom developed SAPUI5 app in the fiori launchpad, we received following error message:
Error
LPD_CUST Settings:
LPD_CUST_settings
Component.js
sap.ui.define([
"sap/ui/core/UIComponent"
], function (UIComponent) {
"use strict";
return UIComponent.extend("***.***.***.Component", {
metadata : {
manifest: "json"
},
init : function () {
UIComponent.prototype.init.apply(this, arguments);
}
});
});
Target Mapping:
Target Mapping
Semantic Object:
Semantiv Object YCEI_BPUPLOAD_SEM exists in the Transaction /n/UI2/SEMOBJ
The App is starting as a standalone application via the index.html. But if we try to launch it on the SAP Fiori Launchpad, the error message appears.
We also tried following component.js where we entered the value of the Additional Information property in the LPD_CUST transaction but we received the same error.
jQuery.sap.declare("***.***.***.Component");
sap.ui.core.UIComponent.extend("***.***.***", {
createContent : function() {
// create root view
this.view = sap.ui.view({
id : "app",
viewName : "***.***.***.view.App",
type : sap.ui.core.mvc.ViewType.XML,
viewData : { component : this }
});
return this.view;
}
});
(*** are internal components/paths)
All hints are appreciated.
Regards,
Dominic
The error message is linking you to the controller of your application. Please make sure you instantiated the objects correctly. Maybe there is a problem with instantiating an OData Model. Check if you use "new". See syntax below:
https://ui5.sap.com/#/topic/6c47b2b39db9404582994070ec3d57a2.html
You need to use "new" when instantiating an object, for example on your second option:
this.view = new sap.ui.view({
id : "app",
viewName : "***.***.***.view.App",
type : sap.ui.core.mvc.ViewType.XML,
viewData : { component : this }
});
I don't think that's the answer to your problem, but I think it was an error and maybe it can help you somehow.

Meteor: Uncaught Error: Must be attached (delete function)

I have an error in the console every time I'm deleting an item (List) in my Meteor application.
The error in the console is:
domrange.js:337 Uncaught Error: Must be attached
Here is the function, I can't understand where come from this error:
Lists.js
Meteor.methods({
'lists.remove'(listId) {
check(listId, String);
const list = Lists.findOne(listId);
if (list.owner !== this.userId) {
throw new Meteor.Error('not-authorized');
}
Tasks.remove({"listId": listId});
Lists.remove(listId);
},
All is working properly in the application but do you know where this error can come from ?
Ps: I'm using Blaze if it can help
thanks
It seems I found the solution adding a Meteor.isServer or better if (!this.isSimulation) (#MasterAM solution):
'lists.remove'(listId) {
check(listId, String);
const list = Lists.findOne(listId);
if (list.owner !== this.userId) {
throw new Meteor.Error('not-authorized');
}
if (!this.isSimulation) {
Tasks.remove({"listId": listId});
Lists.remove(listId);
}
},
I edited the working code with the help of #MasterAM It'w working now! No Console error anymore.

Object #<Object> has no method 'User'

everyone. I have a problem with my code and Meteor 0.9.4
Here is my code:
Server/publications.js
Meteor.publish('getUsers', function () {
var loggedInUser = Meteor.User();
if (Roles.userIsInRole(loggedInUser, ['admin'])) {
return Meteor.users.find({}, {fields: {
_id: 1,
emails: 1,
roles: 1
}});
}
this.stop();
return;
});
Lib/router.js
Router.map(function() {
this.route('dashboardUsers', {
layoutTemplate: 'dashboardLayout',
path: "/dashboard/users",
waitOn: function() {
return Meteor.subscribe('getUsers');
}
});
});
When I run meteor app, I have the following error:
=> App running at: http://localhost:3000/
I20141019-18:21:50.827(4)? Exception from sub 8CRiG3Jmdv4mohPhd TypeError: Object #<Object> has no method 'User'
I20141019-18:21:50.949(4)? at null._handler (app/server/publications.js:3:31)
I20141019-18:21:50.950(4)? at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1594)
I20141019-18:21:50.950(4)? at _.extend._runHandler (packages/ddp/livedata_server.js:943)
I20141019-18:21:50.950(4)? at _.extend._startSubscription (packages/ddp/livedata_server.js:769)
I20141019-18:21:50.951(4)? at _.extend.protocol_handlers.sub (packages/ddp/livedata_server.js:582)
I20141019-18:21:50.951(4)? at packages/ddp/livedata_server.js:546
If you have a look at the docs for Meteor.user, you'll see it works everywhere except publish functions. You need to do:
var loggedInUser = Meteor.users.findOne(this.userId);
The error your getting is because of the upper-case 'u' in Meteor.User it should be Meteor.user.
However, as David Weldon pointed out you'll need to use Meteor.users.findOne(this.userId) inside of publish functions.
For anyone else running into the error Object #<Object> has no method 'user' when trying to access Meteor.user() be sure you have the accounts-base package.

Template.meteorError.rendered doesn't work in errors meteor package

I am trying to use meteor-errors package in my meteor project.
It has two main files with javascript code:
errors_list.js:
Template.meteorErrors.helpers({
errors: function() {
return Errors.collection.find();
}
});
Template.meteorError.rendered = function() {
var error = this.data;
Meteor.defer(function() {
Errors.collection.update(error._id, {$set: {seen: true}});
});
};
errors.js:
Errors = {
// Local (client-only) collection
collection: new Meteor.Collection(null),
throw: function(message) {
Errors.collection.insert({message: message, seen: false})
},
clearSeen: function() {
Errors.collection.remove({seen: true});
}
};
But looks like Template.meteorError.rendered method doesn't work. And I can't set status of elements from my error's collection as seen: true.
When I call for example:
(server)
throw new Meteor.Error 401, "You need to login to add a new address"
(client)
Meteor.call "verify_address", address, name, (error, result) ->
if error
Errors.throw error.reason
I got this error message in my markup, but my browser console shows:
Errors.collection.find().fetch()
[Object]
_id: "MZ8TzpsKCXaeC33Jn"
message: "Address not the correct size"
seen: false
__proto__: Object
And message's seen attribute is still "false".
The initial problem was that an error has a 'X' icon that does not remove the error when clicked. How are we supposed to remove the errors?
The reason for the strange behavior is, you are manually throwing a Meteor.Error whereas your template is bound to a collection which is populated by calling Errors.throw(message)
Try this:
Errors.throw('You need to login to add a new address');

Categories

Resources