Is createStratergy a function? - passport.js

passport.use(User.createStrategy());
^
TypeError: User.createStrategy is not a function
I dont know like docs has it repo has it .. But I get it even after installing latest packages of passport and imported them .

Are you exporting createStrategy function from User class? In general passport.use will have two parameters(name,strategy). This strategy will be based on the idp you are using.

Related

Using music21j in node js, not in browser

I'm attempting to run music21j in node js ( repo link , npm link ).
I get ReferenceError: self is not defined
When trying to simply initialize music21j:
const music21 = require('music21j');
const n = new music21.note.Note('F#');
Does this mean it's not possible to run outside of the browser, or am I somehow initializing to the wrong environment?
The github documentation states
...or use it in your javascript/typescript project
, hence my confusion.
From the github repo:
At present it's not possible to run outside of the browser. :-( But we're working on removing certain JQuery patches that should make it easier to do. You may however need to use ES6-style imports.

Firebase docs reference unknown module

Firebase has this piece of information here at https://firebase.google.com/docs/functions/locations:
Client-side location selection for callable functions Regarding the callable function, client callable setups should follow the same guidelines as HTTP functions. The client can also specify a region, and must do so if the function runs in any region other than us-central1.
To set regions on the client, specify the desired region at
initialization:
var functions = firebase.app().functions('us-central1');
I've been trying to find which node module firebase is referring to but I have had no luck.
I know that it is not 'firebase-admin' or 'firebase-functions' but thats about it.
Anyone have any ideas what this might be referring to?
Edit:
I have now also tried using this with the imports require('firebase') and require('firebase/app') (as suggested) but neither of those seem to work. I also tried generating the app with const app = firebase.initializeApp({}); and then running app.functions("region") or app().functions("region") but i keep receiving TypeErrors saying functions is not a function and app is not a function respectively.
firebase.app().functions('us-central1'); is a part of the firebase-js-sdk. With source code documented on GitHub
NPM component is #firebase/functions, that is documented on the npmjs.com.
However, it is not intended for standalone usage, and should be used along with package Firebase.
You can install it using:
$ npm i firebase

Implementing authentication with passport / node.js and getting error

I had already implemented authentication for the app I'm working on but am trying to refactor it based on a recent tutorial I did which I thought was very clear and also involved adding facebook / google / twitter auth which I would like to do.
So far, I've updated the user model and defined my local strategy for signup but when I go to try and run the app now, I'm getting an error. I have the app uploaded to github and wondered if somebody would be able to check it out and see where I'm going wrong. The error is pointing to a part of the index file until node_modules / express but I cannot work out what's up and I'd like to know before I proceed further.
Latest commit is under: https://github.com/DaveBage83/friendly-invention
Thanks!
A few things for you notice.
1 - Do not commit the node_modules folder. Once you have all your dependencies in the package.json file, the npm install will download all of for you again.
2 - This code is full of erros. I won't put everything here, I believe you find them by yourself. Otherwise, put the specific code here, so we can help you out.
About the question:
In you app.js file.
...
authRoutes = require('./routes/index')(app, passport)
...
If you look at the ./routes/index, you'll see that it is exporting a route object, witch does not expect the two parameters. (e.g. (app, passport)).
Hope it can still help you.

Can't figure out how to get write access to work

I'm talking to Nest Cloud API using Nodejs using firebase node module. I'm using accessToken that I got from https://api.home.nest.com/oauth2/access_token, and this seems to work. My Nest user account got prompted to "accept" this request, which I did and my app is listed in the Nest Account "Works with Nest" page so all looks good. I use this accessToken in call to authWithCustomToken and that works and my Nodejs application requested read/write permission (See https://developers.nest.com/products/978ea6e2-c301-4dff-8b38-f63d80757162). And reading the Nest thermostat properties from https://developer-api.nest.com/devices/thermostats/[deviceid] works, but when I try and write to hvac_mode like this:
this.firebaseRef = new Firebase("https://developer-api.nest.com");
this.myNestThermostat = this.firebaseRef.child("devices/thermostats/"+deviceId);
this.myNestThermostat.set("{'hvac_mode': 'off'}", function (error) { ... }
and this always returns:
FIREBASE WARNING: set at /devices/thermostats/fwxNBtjaok6KZJbSXhf2azuBmGSvkcjK failed: No write permission(s) for field(s): /devices/thermostats/fwxNBtjaok6KZJbSXhf2azuBmGSvkcjK
(where the deviceId is what I see when I enumerate my devices, I only have one, so I'm pretty sure it is correct).
Any ideas?
Well, isn't that always the case, I found an answer already. Turns out if I create a firebase reference to the property itself like this:
var propertyRef = this.myNestThermostat.child(name);
Then the following succeeds:
propertyRef.set(value, function (error) { ...
The firebase documentation was misleading on this because it led me to believe I could write this:
this.myNestThermostat.set("{'hvac_mode': 'off'}", function (error) { ... }
which technically should have worked, but I guess that would mean I'd need write access on the whole of this.myNestThermostat, which I don't. Tricky.
Anyway I'm happy because it works now, yay! Firebase + nodejs rocks!

useradmin problem adding user (Call to undefined method Auth_ORM::register())

When I try to add a user this is the error I get:
ErrorException [ Fatal Error ]: Call to undefined method Auth_ORM::register()
It does not make any sense. I added ORM and AUTH... For some reason it does not work.
I guess you are referring to the useradmin module of mixu (https://github.com/mixu/useradmin) for the Kohana php framework.
This problem goes away if you add the module BEFORE the auth and orm modules in bootstrap.php
There's no such thing as a register method in Auth. You'll have to enter the details into the database using ORM. The User model hashes the password automatically.
https://github.com/kohana/orm/blob/3.1%2Fmaster/classes/model/auth/user.php#L53

Resources