Devise: How to create a private admin role? - ruby

I have a simple Rails 3 blog app that needs an admin user so I can restrict creating and editing blog entries to the admin. I've used devise before, but only for users that are public and can be created by anyone. I don't want the ability to create an admin to be publicly accessible. How should I configure devise to be able to have an admin user?
Update:
After creating an Admin model, you might want to know how to create an admin that can log in (since you won't be able to register them on the front-end).

Have a look at the HOWTO in Github. There are basically two options:
Create a separate admin model
Add a admin attribute to the existing user model
I personally prefer option 1 for larger applications which tend to have different views for admins and normal users. For smaller apps I would recommend option 2.

Related

UserNotLicensed :User does not have license to use <ModernProject> with <ReadOnly> access

I am using below code to create CRM Client
var conn = new CrmServiceClient($#"AuthType=ClientSecret;url={organizationUri};ClientId={clientId};ClientSecret={clientSecret}");
Above code is throwing me "UserNotLicensed :User does not have license to use with access" error
I have also followed this article for creating application user. which is not possible as user needs to be created using power platform.
https://www.ashishvishwakarma.com/Dynamics-365-Single-Tenant-Server-2-Server-Authentication-Azure-Active-Directory-Access-Token/
Mine looks like
Also, as shown in the article I am not able to navigate to "New User" form. It keeps redirecting to Office Admin page. where I am not sure if I have permission to create. Let's say I make Admin do that, will Admin have option to associate User with application ?
creating application user. which is not possible as user needs to be
created using power platform.
what do you mean by this? You first need application user which should be created via Azure AD as app registration as mentioned in article and then you need to go to admin.powerplatfrom.com, select your env and then you see s2s users. Onye you click here it will give you list of all your s2s users (including the one you created). Add this s2s user in your env and assign particular security role (in most cases systemadmin). This should solve your issue

Laravel Admin with controller level permissions

what I want to create is Laravel 5.2 Admin and there are around 200 users who will use it with different permissions, so you can say 200 roles with different permissions.
I was planning to eliminate the role part from the picture and create some slug based mechanism, slugs will be related to controller public functions in short routes.
In Admin panel superuser will be able to assign permissions to user on controller functions with slugs.
Is this possible with any existing laravel package currently? If not then what will be the optimal solution you guys propose.
I always use Spatie Package, it is very flexible. You can manage role & permissions or only permissions. It is full of functions that make it easy. Check the documentation.
spatie-laravel-permission

Headstart needed for re-using the register functionality in Laravel 5.0

I am building a Laravel 5.0 project. With this the admin section is only accessible for registered users. I have added for example a user type to the User model and want to create and edit users using an admin module instead of the standard registration form in /auth/register.
But I cannot seem to find how to disable /auth/register for the outside world, but also cannot create my own CRUD for managing users.
So my main two questions are:
How can I reuse the password encryption in my own create and update functionality
How can I disable /auth/register for the not logged in users?
Thanx in advance

How do I manage two different authentication in Laravel?

since laravel's built in authentication uses user model? For example I want to separate the admin from the user so I will build two different layers in my application, the admin and the user. How can I achieve this to laravel since it's default auth uses users table and user model?
In my opinion, there's no real need to separate the two. Administrators and typical users can exist on the same database table, because they are both users but can have different permissions.
It seems like you're just looking for a typical permissions system (ACL). There's multiple packages available that can help you handle this.
Orchestra Auth
Sentinel
Entrust
Normally as an admin is still an user you give them a role column and let say you have : users, moderators and admins. Then you got role 0,1,2 for them. Just make it an enum and if you need to check in Laravel use : Auth::user()->role == 2 for example of admin rights :)

Magento how to remove specific widgets in admin, so that client only sees relevant widgets

By default, Magento shows different widget types as options in the backend, such as 'Cms Page Link' and 'Catalog Category Link'. However, I want to provide my client only with the theme's relevant widgets, so I want to be able to remove some widgets, at least as an admin option.
The options for the backend are set via the respective core modules /etc/widget.xml. What is the best way to override this, without a core hack?
Any suggestion would be much appreciated!
#Daco
Magento has features to implement the above. It is achieved with the help of "ROLES" and "USERS" in the system tab of magento admin panel.
Solution
Create a role for your client "client_xyz" by going to
System->Permission->Roles.
Add Resources to the role, these resources are the links that you
would like to restrict the users upon or grant them permissions.
After creating the roles and resources, create a user to be given to the client. The Users can be created under System->Permissions->Users.
Create the users assign the roles that are already created. And now when the users login using this newly created credentials. They will only see what is granted by the Admin.

Resources