Login user with temporary roles?

Author Message

Marco Rogers

Monday 03 January 2011 12:46:54 pm

I have a scenario I'm not sure how to solve. I have a site that has various restrictions on it including network access. If you access the site from a certain location, you can bypass login and get a guest account. You do this by entering your email and some other user info so we can locate your account.

However, instead of logging you in with a guest account, we would like to log you in with your own account with restricted privileges. This is handy so we can still track who you are when you take various actions. Rather than doing permission checks everywhere, it would be better if we could temporarily change the roles assigned to the user for the duration of their session.

I've looked eZRole::assignToUser but that will actually permanently add the guest role to the user. Is there a way to temporarily assign roles?

:Marco

Peter Keung

Tuesday 04 January 2011 6:56:15 am

Sounds like the solution is to create a new user account on the fly (in a user group that has the desired permissions) and then log that user in.

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

Marco Rogers

Tuesday 04 January 2011 12:12:10 pm

This doesn't work because we want the temporary account to still be connected to the real user. I was thinking of some feature where a temporary user object would have a reference back to the official user. But that involves custom ezuser objects and such. I was hoping it could be simpler. All I need is temporary privileges.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:27:11
Script start
Timing: Jan 31 2025 01:27:11
Module start 'layout'
Timing: Jan 31 2025 01:27:11
Module start 'content'
Timing: Jan 31 2025 01:27:11
Module end 'content'
Timing: Jan 31 2025 01:27:11
Script end

Main resources:

Total runtime0.0273 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 588.1328151.2109
Module start 'layout' 0.00460.0041 739.3438220.6953
Module start 'content' 0.00870.0167 960.0391997.7266
Module end 'content' 0.02550.0018 1,957.765633.9766
Script end 0.0273  1,991.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003011.0625140.0002
Check MTime0.00124.2182140.0001
Mysql Total
Database connection0.00051.799610.0005
Mysqli_queries0.00217.745830.0007
Looping result0.00000.044510.0000
Template Total0.00134.710.0013
Template load0.00103.708110.0010
Template processing0.00030.946910.0003
Override
Cache load0.00072.479610.0007
General
dbfile0.00279.988380.0003
String conversion0.00000.029640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs