Wednesday, 4 February 2015

keystone more deeper -- supperAdmin (only implementation)


I have one sample project for supper Admin:

https://github.com/wangpingsx/keystone_supperAdmin.git

This commit view shows all changes I made for the supper admin functionality, which compared with default yeoman keystone template project.

https://github.com/wangpingsx/keystone_supperAdmin/commit/1ebec0b6e013c7a8b84746efc80e563f14673a4f

However, to have supper admin functionality for your project, you don't need do all of them. So the simple implementation is:

1. Add supperAdmin field for your user model:

https://github.com/wangpingsx/keystone_supperAdmin/blob/1ebec0b6e013c7a8b84746efc80e563f14673a4f/models/User.js

You can directly copy my User.js file and replace your User.js in your project.

2. Add a authorization checking middleware:

https://github.com/wangpingsx/keystone_supperAdmin/blob/1ebec0b6e013c7a8b84746efc80e563f14673a4f/routes/middleware.js

You can directly copy my middleware.js and replace yours.

3. This change is not necessary. Because it is used to create you a supper Admin. Alternatively, you can change your database manually.

https://github.com/wangpingsx/keystone_supperAdmin/blob/1ebec0b6e013c7a8b84746efc80e563f14673a4f/updates/0.0.2-admins.js

Again, you can copy my code into your project directly.

After that you need restart your keystone, a new supper Admin will be created -- userxx@keystonejs.com password is admin.

































No comments:

Post a comment