Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
How can I add a user with KeystoneJS if I don't have any users?

Sorry if this is an incredibly basic question but I can not find any helpful information out there.

I used the yeoman keystone generator to create a keystone project but MongoDB wasn't working when I ran the generator so the user didn't get created. I can not find any information on how to add the user.

Here is what I tried:

I added this to the routes/views/index.js file so it would get executed when the page loads:

var user = new User({
    name: { first:'matt', last:'x' },
    email: 'me@m.com',
    password: 'password',
    isAdmin: true
});

user.save(function (err) {
    if (err) {
        // handle error
        return console.log(err);
    }

    // user has been saved
    console.log(user);
});

This added a user to the database, but I get this error when I try to login:

Sorry, an error occurred loading the page (500)

Must supply api_key

How do I resolve this?

Thanks for any help.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use the built-in update functionality to add a new user. Add this code to an updates/0.0.2-admins.js file:

var keystone = require('keystone'),
    User = keystone.list('User');

exports = module.exports = function(done) {
    new User.model({
        name: { first: 'Admin', last: 'User' },
        password: 'admin',
        isAdmin: true
    }).save(done);
};

Can you post the full error regarding your API key, though?

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!