This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
    erodriguez
    
            
            
                    
                                            
        
    
        I'm using RainLab/User to management my users, and after ban a specific user I want to kill his session but I'm not sure where to put that.
Check on layout ..
I can write my own code to check in the layout if the current session has the flag ban activated or not. But it will be a bad performance, right? And write this loginc on layout is the best way?
    daftspunky
    
            
            
                    
                                            
        
    
        If you change their persist_code it will sign them out.
$user->persist_code = str_random();
$user->save();
                    
    erodriguez
    
            
            
                    
                                            
        
    
        What do you think bro? I had to extend Throttle using beforeSave event
Throttle::extend(function ($model) {
    $model->bindEvent('model.beforeSave', function () use ($model) {
        $originalModel = Throttle::find($model->id);
        // kill his current session
        if ($model->is_banned && !$originalModel->is_banned) {
            $user = User::find($model->user_id);
            $user->persist_code = str_random();
            $user->save();
        }
    });
});
I could not access to $model->original['is_banned'] because of the original property is protected.
Last updated
1-3 of 3