I think I can make that work. Thanks for sharing that.
I agree it’d be nice if that were the case.
I think I can make that work. Thanks for sharing that.
I agree it’d be nice if that were the case.
Hey.
I know this is an old thread, but I really needed the password reset function on this website function I’m building. I haven’t found any full solution for this anywhere, and this thread is the best help I have had.
So I kind of implemented what @HYR was saying, and I almost got everything working like I need it. The users have access to their own profile in the panel and can edit the password. It works fine I think.
Hoowever I just need help with one last thing: when they put in a new password, then click on “save”, I need them to be redirected to the frontend of the site. Clicking the “cancel” button does this already (because the users get redirected to /panel/users and they don’t have access). But I need find a way to set this up on save.
Is there a way to do this easily? Here is what I’ve got in my config file:
c::set('roles', array(
array(
'id' => 'registered',
'name' => 'Registered',
'default' => true,
'permissions' => [
'*' => false,
'panel.access' => true,
'panel.access.users' => function() { return strstr(kirby()->path(), 'users/'.$this->user()->username().'/') ? true : false; },
'panel.user.delete' => false,
'panel.user.read' => function() { return $this->user()->is($this->target()->user()) ? true : false; },
'panel.user.update' => function() { return $this->user()->is($this->target()->user()) ? true : false; },
]
),
array(
'id' => 'admin',
'name' => 'Admin',
'panel' => true
)
));
// Restrict panel access for registered users
if ($user = site()->user() and $user->hasRole('registered')) {
// Additional CSS for registered users
kirby()->set('option', 'panel.stylesheet', [
'assets/panel-css/panel.css'
]);
// Ensure customers don't stray onto the wrong page
if (strpos(kirby()->request()->url(),'/panel') and strstr(kirby()->path(),'users/'.$user->username()) === false) {
go(site()->url());
}
}
I’m stuck and I would love some help! If anybody has some pointers of how I should do this. Thanks!
*edit:
If anybody needs this down the line, I got the functionality I needed by modifying the panel core in panel/app/controllers/users.php, in the edit() function (l. 91):
From
$self->redirect($user, 'edit');
to
$self->redirect('users');