Welcome Guest, Not a member yet? Register   Sign In
safely customize myth auth
#1

i'm new using ci4,
i already customized the registration so it can send user's fullname,
i followed the docs https://github.com/lonnieezell/myth-auth...tending.md, but it is doesnt escape the value,
where can i put the escape before controller save data to database

and  i tried to add select role in registration, so when user register their account, it also add their account to auth_groups_users table,
i dont find the docs for it, so what i did is get the id from the user recently added to the table, and add this user to the group according to the role they were inputed, and i add this code in authController from myth auth, is it recommended way? if its possible i want to add those code in my own controller, but im new here.
Reply
#2

(This post was last modified: 07-28-2022, 12:26 AM by manager.)

(07-22-2022, 06:36 PM)nahcode Wrote: i'm new using ci4,
i already customized the registration so it can send user's fullname,
i followed the docs https://github.com/lonnieezell/myth-auth...tending.md, but it is doesnt escape the value,
where can i put the escape before controller save data to database

Hi. If i don't get you wrong when you use standard Myth:Auth's models (it extends CI's models) to save data to db there is no need to escape values because query builder will do it for you. Look to this part of CI documentation for more info: Escaping data

PHP Code:
<?php

class NewsModel extends Model
{
    public function 
getNews($slug false)
    {
        if (
$slug === false) {
            return 
$this->findAll();
        }

        return 
$this->where(['slug' => $slug])->first();
    }


With this code, you can perform two different queries. You can get all news records, or get a news item by its slug. You might have noticed that the $slug variable wasn’t escaped before running the query; Query Builder does this for you.

(07-22-2022, 06:36 PM)nahcode Wrote: .... and i add this code in authController from myth auth, is it recommended way?

No. It's wrong way. Recommended way is to create your own AuthController.php which extends Myth:Auth's AuthController.php inside your App's Controllers folder.

(07-22-2022, 06:36 PM)nahcode Wrote: and  i tried to add select role in registration, so when user register their account, it also add their account to auth_groups_users table,
i dont find the docs for it, so what i did is get the id from the user recently added to the table, and add this user to the group according to the role they were inputed, and i add this code in authController from myth auth, is it recommended way? if its possible i want to add those code in my own controller, but im new here.

The documentation explains the fundamentals of how to use and extend the package (modify) because the use needs of users is unpredictable. Do not modify the contents of any of this code directly, including views, config files, etc. Instead, you should copy the file to the appropriate spot in your application, and modify the namespace of the file. This allows you to upgrade to newer versions without overwriting your own code.

In your case you should extend the register's views and AuthController with php spark auth:publish command and after modify AuthController's register() and attemptRegister() methods according by your needs.

You may also use Myth:Auth Discussions to get support.
Reply
#3

The docs no long are in the download of Myth/Auth to get the docs you need to download the complete GitHub project.
There is a docs folder in the download one from GitHub.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB