Seeding databases
You're almost ready to use the new routes to create or remove an admin page. The last thing you need to do is to seed the database so you have at least one known Admin account at the beginning. This is very easy with the PostgreSQL frontend utility: pgadmin4.
One problem you have right away is that a password must be converted into a hash value before serializing to the database. For a quick workaround, you can use a known password hash for the seed account.
You can check out Vapor's implementation of the BCrypt library. BCrypt is a popular hashing algorithm that has configurable complexity and handles salting automatically. Locate the unit tests for the BCrypt library on GitHub: https://github.com/vapor-community/bcrypt/blob/master/Tests/BCryptTests/BCryptTests.swift ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access