Authenticating via Github (using everyauth) - javascript

I'm using everyauth, and am having trouble authenticating it with github. It seems like all of the steps I've followed thus far are correct, but it keeps telling me it cannot GET /auth/github when clicking the "connect with github" link.
Here's a gist with my code: https://gist.github.com/2641260
Any help would be greatly appreciated!

I know its probably too late to answer, but I just had the same problem and figured out the solution.
Its really simple.
Place the EveryAuth code before the app.configure() code.
This way: Fork of your Gist

Not sure if this will help but have you tried adding the ".entryPath" chainable parameter?
everyauth.github
.entryPath('/auth/github')
.appId("APP_ID")
.appSecret("APP_SECRET")
.findOrCreateUser( function (sess, accessToken, accessTokenExtra, ghUser) {
console.log('find user')
// return usersByGhId[ghUser.id] || (usersByGhId[ghUser.id] = addUser('github', ghUser));
})
.redirectPath('/');

Related

Bind class instance function to v8::FunctionTemplate

I'm fairly new to C++ and v8 in general, and I wanted to build a native node.js addon, but now I'm stuck on something quite simple IMO, but I can't figure out what the issue is, the error message
C:\Path\To\Project\File.cpp(50): error C2664: 'v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate *,v8::FunctionCallback,v8::Local<v8::Value>,v8::Local<v8::Signature>,int,v8::ConstructorBehavior,v8::SideEffectType)': cannot convert argument 2 from 'v8::Local<v8::Value> (__cdecl *)(const v8::FunctionCallbackInfo<v8::Value> &)' to 'v8::FunctionCallback' [C:\Path\To\Project\build\node_gui.vcxproj]
is not that helpful.
I've got the following code,
v8::Local <v8::Object> Window::GetFunctions() {
v8::Local <v8::Object> DrawFunctions = v8::Object::New(isolate);
v8::Local <v8::FunctionTemplate> bgfnc = v8::FunctionTemplate::New(isolate, &Window::BackgroundCB);
DrawFunctions->Set(v8::String::NewFromUtf8(isolate, "background"), bgfnc);
return DrawFunctions;
}
void Window::Background(const v8::FunctionCallbackInfo <v8::Value> &args) {
v8::Isolate *isolate = args.GetIsolate();
renderer->Background(args[0]->NumberValue(), args[1]->NumberValue(), args[2]->NumberValue());
}
v8::Handle <v8::Value> BackgroundCB(const v8::FunctionCallbackInfo <v8::Value> &args) {
return ((Window*)v8::External::Cast(*(args.Data())->Value())->Background());
}
I want to create an object that contains a list of functions, the functions' callbacks would be member functions of the Window class. I know this has been asked before here, which worked once using a non-member function but otherwise not.
Thanks
Sidenote: I've looked far and wide for v8 docs that are suitable for beginners, the nodesource ones don't explain what the parameters mean or rarely give a thorough example of how to use the function / class, if anyone knows some better docs, that would be great, thank you.
Thanks to the gracious and prompt help of the community, I was able to quickly and effortlessly resolve this issue. Turns out, when writing NodeJS addons, it's a good idea to use NodeJS's own N-API, as the documentation is simpler, clearer, and most importantly, existant.

Following a redirect for images in HTML

Apologies if the question isn't correctly worded, but here it goes: I currently have a website which needs to display a certain image, however, the link provided to me is a link that redirects to the image.
So think www.linktoimage.com/foo, which redirects me to my actual image's url, so for example, https://i.imgur.com/76lLZAn.png.
Unfortunately this is a requirement to the project I am working on for several reasons and I can't really think of a way to get around this.
For the record, I am using meteor with the blaze template engine, in case that helps. A way I thought of getting this done may be through using a helper, which will follow the redirect for me, and somehow grab the ultimate url. So something like this:
Template.myTemplate.helpers({
getMyImage: function (proxyUrl) {
var actualAddress
// somehow get the images actual address...
return actualAddress
}
})
Then in my html file:
<template name="myTemplate">
<div>
<img src="{{getMyImage 'proxyUrl'}}"
<div>
</template>
Of course if there is a better way to do this just through the HTML that would be fantastic too. Unfortunately right now, I am clueless on how I would get the actual URL.
Thanks!
Edit: essentially I want to do this, but using JavaScript instead of PHP.
Edit2: possibly found a way to get around this, though it is not quite working and has some problems due to it being async. Basically it would be using meteor's HTTP library:
Template.myTemplate.helpers({
getMyImage: function () {
var proxyUrl = 'http://www.tablotv.com/client-paywall-snapshots/web'
return HTTP.call('GET', proxyUrl, function (err, result){
console.warn('hereeee', result, err)
})
}
})
However I am getting the following error:
network at XMLHttpRequest.xhr.onreadystatechange
I can imagine this has something to do with it being async, perhaps? Anyway, am I on the right path now? How could I get this working?

Temperamental `nestRemoting()` sometimes can't find relation

I'm implementing the (not so well documented) loopback method nestRemoting() as follows:
module.exports = function(MyModel) {
MyModel.on('attached', function() {
MyModel.nestRemoting('relationName');
});
}
However this seems to be very temperamental. Sometimes it works, but most of the time I get:
Relation `relationName` does not exist for model `MyModel`
at ....stacktrace....
.....
Does anyone know why this error might be occurring?
So, I found the solution only moments after posting - you can only do nestRemoting after the model has been attatched... not attached. Simple spelling mistake can fix all woes.
Perhaps this post will help someone else trying to nest endpoints.

PhantomJS+Capybara+RSpec get default PhantomJs Example Domain

When I set js: true in my test, I get the default website:
"This domain is established to be used for illustrative examples in documents. You may use this"...
But when I dissable js: true, I get my right webpage. Also, I tryed with js_erros: false but does not work.
it 'my tests', js: true do
# ....
end
Anyone knows something about it? Anything to read? I looked for a while for a solution without results.
Any help will be appreciated.
Thanks.
Switch your something_url to something_path.
I was having the same problem and this approach solved it. I hope it helps!

How to display inputs in Jamsine SpecRunner?

I started using Jasmine to test javascript code and its working fine. But I would like to display inputs to the test suite in specrunner.html.
I tried HtmlReporter() and TrivialReporter() but no luck.
SPEC CODE:
checkAddition("TEST_SUITE","Test INPUTS1",getResult(2,3),5);
checkAddition("TEST_SUITE","Test INPUTS2",getResult(3,8),11);
function checkAddition(suite_name,testcase,result,equalto){
describe(suite_name, function() {
it(testcase, function() {
expect(result).toEqual(equalto);
});
});
}
JavaScript CODE:
function getResult(input1,input2){
return input1+input2;
}
OUTPUT :
EXPECTED OUTPUT :
I need to display inputs that looks like expected output (I edited code in browser using firebug to share expected output).
Please help me. Help would be appreciated :)
The built reporters won't do this. You either need to need to hack the innards of those built in reporters to do this (you're on your own with this route), or create your own reports from scratch (see here for some examples).
But I find this to be a strange request. Perhaps there is a cleaner way to achieve your goal, whatever that may be. Maybe a test suite isn't what you want if you want this info.

Categories