r1037 - in xwiki/trunk/src/main: java/com/xpn/xwiki java/com/xpn/xwiki/user/impl/xwiki resources web/templates
Ludovic Dubost
ludovic at users.forge.objectweb.org
Sun Apr 9 21:41:52 CEST 2006
Author: ludovic
Date: 2006-04-09 21:41:52 +0200 (Sun, 09 Apr 2006)
New Revision: 1037
Modified:
xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/MyPersistentLoginManager.java
xwiki/trunk/src/main/resources/ApplicationResources.properties
xwiki/trunk/src/main/resources/ApplicationResources_en.properties
xwiki/trunk/src/main/resources/ApplicationResources_fr.properties
xwiki/trunk/src/main/web/templates/editprefs.vm
xwiki/trunk/src/main/web/templates/login.vm
Log:
Allowed to keep the login cookie only for the browser session
Show checkbox to choose to remember login
Fix skin which is protected by user rights, use default skin instead
Removed baseskin from preferences
Added link to skin page in preferences
Added field auth check active in preference
Fix active check for superadmin and guest user
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java 2006-04-09 12:03:53 UTC (rev 1036)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java 2006-04-09 19:41:52 UTC (rev 1037)
@@ -1072,6 +1072,15 @@
} catch (Exception e) {
skin = "default";
}
+ try {
+ if (skin.indexOf(".")!=-1) {
+ if (!checkAccess("view", getDocument(skin, context), context))
+ skin = Param("xwiki.defaultskin", "default");
+ }
+ } catch (XWikiException e) {
+ // if it fails here, let's just ignore it
+ }
+
context.put("skin", skin);
return skin;
}
@@ -2598,7 +2607,16 @@
}
public int checkActive(XWikiContext context) throws XWikiException {
+ return checkActive(context.getUser(), context);
+ }
+
+ public int checkActive(String user, XWikiContext context) throws XWikiException {
int active = 1;
+
+ // These users are necessarly active
+ if (user.equals("XWiki.XWikiGuest")||(user.equals("XWiki.superadmin")))
+ return active;
+
String checkactivefield = getXWikiPreference("auth_active_check", context);
if (checkactivefield.equals("1")) {
String username = context.getUser();
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/MyPersistentLoginManager.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/MyPersistentLoginManager.java 2006-04-09 12:03:53 UTC (rev 1036)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/MyPersistentLoginManager.java 2006-04-09 19:41:52 UTC (rev 1037)
@@ -37,6 +37,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.securityfilter.authenticator.persistent.DefaultPersistentLoginManager;
+import org.securityfilter.authenticator.FormAuthenticator;
import org.securityfilter.filter.SecurityRequestWrapper;
public class MyPersistentLoginManager extends DefaultPersistentLoginManager {
@@ -82,25 +83,30 @@
}
}
+ // Let's check of cookie should be a session cookie
+ boolean sessionCookie = !("true".equals(request.getParameter("j_rememberme")));
String cookieDomain = getCookieDomain(request);
// create client cookie to store username and password
Cookie usernameCookie = new Cookie(COOKIE_USERNAME, username);
- usernameCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
+ if (!sessionCookie)
+ usernameCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
usernameCookie.setPath(cookiePath);
if (cookieDomain!=null)
usernameCookie.setDomain(cookieDomain);
addCookie(response, usernameCookie);
Cookie passwdCookie = new Cookie(COOKIE_PASSWORD, password);
- passwdCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
+ if (!sessionCookie)
+ passwdCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
passwdCookie.setPath(cookiePath);
if (cookieDomain!=null)
passwdCookie.setDomain(cookieDomain);
addCookie(response, passwdCookie);
Cookie rememberCookie = new Cookie(COOKIE_REMEMBERME, "true");
- rememberCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
+ if (!sessionCookie)
+ rememberCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
rememberCookie.setPath(cookiePath);
if (cookieDomain!=null)
rememberCookie.setDomain(cookieDomain);
@@ -109,7 +115,8 @@
String validationHash = getValidationHash(username, password, request.getRemoteAddr());
if (validationHash != null) {
Cookie validationCookie = new Cookie(COOKIE_VALIDATION, validationHash);
- validationCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
+ if (!sessionCookie)
+ validationCookie.setMaxAge(60 * 60 * 24 * Integer.parseInt(cookieLife));
validationCookie.setPath(cookiePath);
if (cookieDomain!=null)
validationCookie.setDomain(cookieDomain);
Modified: xwiki/trunk/src/main/resources/ApplicationResources.properties
===================================================================
--- xwiki/trunk/src/main/resources/ApplicationResources.properties 2006-04-09 12:03:53 UTC (rev 1036)
+++ xwiki/trunk/src/main/resources/ApplicationResources.properties 2006-04-09 19:41:52 UTC (rev 1037)
@@ -206,6 +206,7 @@
macros_mapping=Macro Mapping
notification_pages=Notification Pages
auth_active_check=Check Active fields for user authentication
+rememberme=Remember me on this computer
chartwizard=Chart Wizard
chwhide=hide
Modified: xwiki/trunk/src/main/resources/ApplicationResources_en.properties
===================================================================
--- xwiki/trunk/src/main/resources/ApplicationResources_en.properties 2006-04-09 12:03:53 UTC (rev 1036)
+++ xwiki/trunk/src/main/resources/ApplicationResources_en.properties 2006-04-09 19:41:52 UTC (rev 1037)
@@ -206,6 +206,7 @@
macros_mapping=Macro Mapping
notification_pages=Notification Pages
auth_active_check=Check Active fields for user authentication
+rememberme=Remember me on this computer
chartwizard=Chart Wizard
chwhide=hide
Modified: xwiki/trunk/src/main/resources/ApplicationResources_fr.properties
===================================================================
--- xwiki/trunk/src/main/resources/ApplicationResources_fr.properties 2006-04-09 12:03:53 UTC (rev 1036)
+++ xwiki/trunk/src/main/resources/ApplicationResources_fr.properties 2006-04-09 19:41:52 UTC (rev 1037)
@@ -206,4 +206,5 @@
macros_groovy=Pages de Macros Groovy
macros_mapping=Correspondance des Macros
notification_pages=Pages de Notifications
-auth_active_check=Verifier le champ 'Actif' lors de l'authentification
\ No newline at end of file
+auth_active_check=Verifier le champ 'Actif' lors de l'authentification
+rememberme=Mémoriser compte et mot de passe
\ No newline at end of file
Modified: xwiki/trunk/src/main/web/templates/editprefs.vm
===================================================================
--- xwiki/trunk/src/main/web/templates/editprefs.vm 2006-04-09 12:03:53 UTC (rev 1036)
+++ xwiki/trunk/src/main/web/templates/editprefs.vm 2006-04-09 19:41:52 UTC (rev 1037)
@@ -31,7 +31,7 @@
#set($sections = ["params", "skin", "presentation", "editing", "advanced", "registration"])
#set($sectionitemsmap = $xwiki.hashMap)
#set($sectionitemsmap.params = ["multilingual", "language" , "default_language", "authenticate_view", "authenticate_edit", "auth_active_check" ])
-#set($sectionitemsmap.skin = ["skin", "baseskin", "stylesheet", "stylesheets"])
+#set($sectionitemsmap.skin = ["skin", "stylesheet", "stylesheets"])
#set($sectionitemsmap.presentation = [ "title", "version", "webcopyright", "menu", "meta" ])
#set($sectionitemsmap.editing = ["editor", "editbox_width","editbox_height"])
#set($sectionitemsmap.advanced = ["macros_languages", "macros_velocity","macros_groovy", "macros_mapping", "notification_pages" ])
@@ -53,7 +53,14 @@
<td>
#if($prop)
$doc.displayEdit($prop, "${class.name}_${obj.number}_", $obj)
+#if($item=="skin")
+#set($skin = $xwiki.skin)
+#if($skin.indexOf(".")!=-1)
+#set($skindoc = $xwiki.getDocument($skin))
+<a href="$skindoc.getURL()">Customize</a>
#end
+#end
+#end
</td></tr>
#end
</table>
Modified: xwiki/trunk/src/main/web/templates/login.vm
===================================================================
--- xwiki/trunk/src/main/web/templates/login.vm 2006-04-09 12:03:53 UTC (rev 1036)
+++ xwiki/trunk/src/main/web/templates/login.vm 2006-04-09 19:41:52 UTC (rev 1037)
@@ -9,7 +9,6 @@
#end
<div id="xwikicontent">
<form id="loginForm" action="" method="POST">
-<input type="hidden" name="j_rememberme" value="true" />
<input type="hidden" name="xredirect" value="$!request.getParameter("xredirect")" />
<table border="0">
<tr><td>$msg.get("username"):</td>
@@ -18,6 +17,10 @@
<tr><td>$msg.get("password"):</td>
<td><input type="password" name="j_password" value="" /></td>
</tr>
+<tr><td colspan="2">
+<input type="checkbox" name="j_rememberme" value="true" CHECKED /> $msg.get("rememberme")
+</td>
+</tr>
<tr>
<td colspan="2"><input type="submit" value="$msg.get("login")"/></td>
</tr>
More information about the Xwiki-notifications
mailing list