Synyx GmbH & Co. KG Homepage Welcome Guest   | Login
  Search  
  Index  | Recent Threads  | Who's Online  | User List  | Register  | Search  | Help  | RSS feeds
OpenCms 7.0.4 Live-CD available!

Synyx created an OpenCms 7.0.4 Live CD, based on SLAX Linux, which is now available.

If you want to order a free CD copy, please write, including your postal address, to



Quick Go »
Thread Status: Normal
Total posts in this thread: 4
[Add To My Favorites] [Watch this Thread] [Post new Thread]
Author
Previous Thread This topic has been viewed 552 times and has 3 replies Next Thread
Male Hanuchin
Stranger



Joined: Mar 10, 2009
Posts: 4
Status: Offline

Webuserlogin - Forgot his password - Reset password Reply to this Post
Reply with Quote

Hello,

i have a webuser login section and now i need a way, to reset the password and send it to the users email.

When i am not logged in, i can view all user details via

 			CmsUser loadUser = cmsObject.readUser(paramUserName);


But i cant do


cmsObject.setPassword(paramUserName,newPassword);


because i get an exception


org.opencms.security.CmsRoleViolationException


It makes sence, because a guest normally shouldnt be able to change does things, but now i need to do this.

What is the right way to get this solved?

thanks
hanuchin
[Jan 7, 2010 2:08:16 PM] Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Male Flo
Advanced Member
Member's Avatar


Joined: May 7, 2004
Posts: 456
Status: Offline
Re: Webuserlogin - Forgot his password - Reset password Reply to this Post
Reply with Quote

Hi,

One possibility is to store a CmsObject with admin credentials and use this object for changing the password. You can get an admin CmsObject when you register a I_CmsModuleAction. You can store it using OpenCms.setRuntimeProperty(java.lang.Object key, java.lang.Object value)

Flo
----------------------------------------
/**
* Florian Hopf
* Synyx GmbH & Co. KG
*/
[Jan 8, 2010 3:53:32 PM] Show Printable Version of Post        http://www.synyx.de [Link] Report threatening or abusive post: please login first  Go to top 
Male Hanuchin
Stranger



Joined: Mar 10, 2009
Posts: 4
Status: Offline

Re: Webuserlogin - Forgot his password - Reset password Reply to this Post
Reply with Quote

Hmm, i never did this. When i can store this object?
[Jan 15, 2010 8:24:00 AM] Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Male Flo
Advanced Member
Member's Avatar


Joined: May 7, 2004
Posts: 456
Status: Offline
Re: Webuserlogin - Forgot his password - Reset password Reply to this Post
Reply with Quote

Hi,

this is an example of a module action implementation. You create a class like this.


public class ModuleAction implements I_CmsModuleAction {

/**
* @see org.opencms.module.I_CmsModuleAction#initialize(org.opencms.file.CmsObject,org.opencms.configuration.CmsConfigurationManager,
* org.opencms.module.CmsModule)
*/
public void initialize(CmsObject cms, CmsConfigurationManager configManager, CmsModule module) {

try {
cms.getRequestContext().setCurrentProject(cms.readProject("Offline"));
cms.getRequestContext().setSiteRoot("/sites/default");
} catch (CmsException ex) {
log.error("", ex);
}

OpenCms.setRuntimeProperty(Constants.ATTRIBUTE_NAME_ADMIN_CMS_OBJECT, cms);
}


/**
* @see org.opencms.module.I_CmsModuleAction#moduleUninstall(org.opencms.module.CmsModule)
*/
public void moduleUninstall(CmsModule arg0) {

// NOOP
}


/**
* @see org.opencms.module.I_CmsModuleAction#moduleUpdate(org.opencms.module.CmsModule)
*/
public void moduleUpdate(CmsModule arg0) {

// NOOP
}


/**
* @see org.opencms.module.I_CmsModuleAction#publishProject(org.opencms.file.CmsObject,org.opencms.db.CmsPublishList,
* int, org.opencms.report.I_CmsReport)
*/
public void publishProject(CmsObject arg0, CmsPublishList arg1, int arg2, I_CmsReport arg3) {

// NOOP
}


/**
* @see org.opencms.module.I_CmsModuleAction#shutDown(org.opencms.module.CmsModule)
*/
public void shutDown(CmsModule arg0) {

// NOOP
}


/**
* event lifecycle
* @param event
*/
public void cmsEvent(CmsEvent event) {

// NOOP
}
}



Afterwards, in your module, you register the classname with package structure in the module administration (Administration/Module Management/Choose your module/Edit Module) in the field Action Class (e.g. com.synyx.ModuleAction).

Then you can access the CmsObject, which has Admin rights set, from anywhere inside of your application like this:


CmsObject cms = (CmsObject) OpenCms.getRuntimeProperty(Constants.ATTRIBUTE_NAME_ADMIN_CMS_OBJECT)

----------------------------------------
/**
* Florian Hopf
* Synyx GmbH & Co. KG
*/
----------------------------------------
[Edit 1 times, last edit by Flo at Jan 22, 2010 7:01:41 PM]
[Jan 22, 2010 7:01:03 PM] Show Printable Version of Post        http://www.synyx.de [Link] Report threatening or abusive post: please login first  Go to top 
[Show Printable Version of Thread] [Post new Thread]