Comments (7)
That is a good point. Your observation is correct. Looks like this would solve the issue: #49.
If you are in a hurry a workaround could be to create an user via http and then modify it via a command to mongodb. Both steps are ugly, I know π
from ooth.
In our scenario, we'd like to build an interface where an admin user can create other users, but we're running into a host of issues, primarily stemming from a lack of a programmatic interface. Also, calls to the local strategy's register
endpoint can only be made by a user who is not already logged in, which kills the ability for us to use the register
endpoint from the client-side at all.
from ooth.
I had this same issue. I ended up studying insides of ooth and creating something similar that is compatable. I have removed the application specific parts but here it is
const generator = require('generate-password');
const OothMongo = require('ooth-mongo');
const {ObjectId} = require('mongodb');
const { hashSync, genSaltSync } = require('bcrypt-nodejs');
const { randomBytes } = require('crypto');
const SALT_ROUNDS = 12;
const HOUR = 1000 * 60 * 60;
function randomToken() {
return randomBytes(43).toString('hex');
}
function hash(pass) {
return hashSync(pass, genSaltSync(SALT_ROUNDS));
}
class UserImporter {
backend: {
getUserByValue: Function,
insertUser: Function
}
constructor(db) {
this.backend = new OothMongo(db, ObjectId);
}
/// call this to create a user
immmigrate({email, firstName, lastName, phone}) {
if (typeof email !== 'string') {
throw new Error(`Invalid email ${email}`);
}
return this.backend.getUserByValue(['local.email'], email).then(user => {
if (user) {
console.error(`This email ${email} is already registered.`);
return
}
const password = generate.password()
const verificationToken = randomToken();
this.backend.insertUser({
profile: {
firstName,
lastName,
phone
},
local: {
email,
password: hash(password),
verificationToken: hash(verificationToken),
verificationTokenExpiresAt: new Date(Date.now() + HOUR)
},
roles
}).then(_id => { console.info(`User ${email} imported successfully.`);
});
}
}
export default UserImporter
from ooth.
from ooth.
@jonpacker thanks for the feedback, what approach did you end up taking? Is there any library that was helpful to you?
from ooth.
For the specific case of ooth-local
it is now possible to run
ooth.on('register', ({_id, email, verificationToken}) => ...))
await ooth.callMethod('local', 'register', { email, password })
The general idea is that every method registered with ooth.registerMethod
can now be called like that.
from ooth.
For the specific case of
ooth-local
it is now possible to run
ooth.on('register', ({_id, email, verificationToken}) => ...))
await ooth.callMethod('local', 'register', { email, password })
The general idea is that every method registered with
ooth.registerMethod
can now be called like that.
What's the ooth.on event callback for "login", that exist?
from ooth.
Related Issues (20)
- This is not defined. It's defined above in another scope. I can do a pull request if you want me to... HOT 1
- Typescript HOT 3
- ooth-local-emailer url parameter HOT 1
- local-plugin: remember me HOT 3
- TypeError: Ooth is not a constructor HOT 4
- Accessing users' roles through withUser HOC HOT 1
- how to get ooth integrated and deployed in a kubernetes cluster? HOT 6
- prisma backend? HOT 2
- [Backend] Prisma Integration as alternative to mongodb HOT 10
- Passworless login using Twillio HOT 1
- Enhance ooth Documentation
- React Native error "Canβt Find Variable Self" when import { OothClient } from 'ooth-client' HOT 1
- Capcha strategy
- TypeError: ooth.usesSession is not a function
- User serialization / deserialization
- Profile on registration HOT 1
- Ooth Client headers
- oothJwt and reset password
- Is this project still maintained? HOT 1
- Wildcard Sessions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ooth.