Welcome Guest, Not a member yet? Register   Sign In
Basic usage how-to for Shield authentication
#1

I have Shield installed. Registration is working. 

Need simple instructions on how to implement for basic operation:

1. How do I set up user management: add, modify and delete accounts, assign and modify group?

2. How do I restrict access to individual pages and parts of pages?

Thanks!
Reply
#2

Hello @Tbronson , everything you need is in the documentation.

Quote:1. How do I set up user management: add, modify and delete accounts, assign and modify group?
Have you read Shield?
Have you seen the questions in section discussions?
If you have read, can you tell us which part is unclear for you?

Quote:2. How do I restrict access to individual pages and parts of pages?

You need to use filters, here's how to write filters. You can also refer to GroupFilter for more guidance on filters.
Do you need more explanation?
Reply
#3

(This post was last modified: 08-02-2022, 02:17 AM by Tbronson.)

Thanks! My question was poorly worded. I'm looking for working examples of implementation. I guess Shield is so new, maybe none have been done yet? 

I'm not a coder, and I learn how to use best by starting with working examples. For CI4, I took the code from a "Simple CRUD project for CI4" article, and modified from there by reading the CI docs.

(I did read the Shield and related CI docs. I understand how it's implemented--the set-up seems to be pretty much the same as Laravel authentication, which I'm familiar with, as far as filtering pages in routes.)
Reply
#4

Quote:maybe none have been done yet? 

Yes, what you are looking for is not currently in the documentation.
We previously had a request from someone for more clarification in the documents, which led to good changes in the documents.

I think you are the first person to look for practical examples in the implementation and use of the shield.

If the requests are suitable in this context, it seems possible to do this request.

Anyone, if you agree with the request, please let me know.
Reply
#5

I was also looking for a way to remove users from Shield.

All I found was in the discussions this thread https://github.com/codeigniter4/shield/discussions/249 with a link to the migrations to setup the tables for users.

Given there is more than one table that references a user, it might be worth coming up with an SQL query that removes all records in the database related to a user.

Other than the users table (id), the foreign key is user_id.

Users Table
Auth Identities Table
Auth Login Attempts Table
Auth Token Login Attempts Table
Auth Remember Tokens (remember-me) Table
Groups Users Table
Users Permissions Table

From investigating, it seems when the tables were setup, it would be convenient to add a constraint of ON DELETE CASCADE so that user_id foreign key references in other child tables will be deleted in other tables when you delete the user in the users table.

I queried all the constraints in my database and cannot find any DELETE CASCADE so this is not setup.

In that case you will need to run multiple queries to remove the user from all tables.

For example, in phpmyadmin, I ran a SQL command that removes all users with an id in the users table thats more than 1. You could replace > 1 with a = 2 for example, to remove the user with id 2.

DELETE FROM users WHERE id > 1;
DELETE FROM auth_groups_users WHERE user_id > 1;
DELETE FROM auth_identities WHERE user_id > 1;
DELETE FROM auth_logins WHERE user_id > 1;
DELETE FROM auth_permissions_users WHERE user_id > 1;
DELETE FROM auth_remember_tokens WHERE user_id > 1;
DELETE FROM auth_token_logins WHERE user_id > 1;
Reply
#6

Any update on this ? I want to use CI instead of Laravel but it seems alot of docs. are missing or not created. Example would be good for new users like us.
Reply
#7

Why don't you see or use Bonfire2?
https://github.com/lonnieezell/Bonfire2
Reply
#8

(This post was last modified: 10-05-2023, 03:14 PM by murugappan.)

Hi,
Why dont you try Udemy.com. There is a course on using Codeigniter 4 shield by Online Web Tutor. I am learning from it but only sad that it does not cover every aspect in detail - like using JWT. Enough to get started though.

Check it out using this link: https://www.udemy.com/course/codeigniter...ication-v/
Reply
#9

Hi,

Search also on Udemy for Dave Hollingworth with the course "CodeIgniter for Beginners: Build a Complete Web Application" and you have a perfect example
Reply
#10

(This post was last modified: 01-06-2024, 01:24 AM by Corsari.)

(10-06-2023, 09:55 AM)snelledre Wrote: Hi,

Search also on Udemy for Dave Hollingworth with the course "CodeIgniter for Beginners: Build a Complete Web Application" and you have a perfect example

Yes it is

It must be specified that Dave Hollingworth updated his course named "CodeIgniter for Beginners: Build a Complete Web Application"

The course creation date might be misleading but Dave has updated his online course: I have seen the lessons today and the Shield section of the course is brand new.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB