From e9273a97eb479ff180ad29ef1c80a4b58cd2cdcf Mon Sep 17 00:00:00 2001
From: Robin Eklund <robi-ekl@dsv.su.se>
Date: Thu, 4 Aug 2011 16:27:57 +0200
Subject: [PATCH] Small fix to user switching, roles should be correctly reset
 now.

---
 src/main/java/se/su/dsv/scipro/SciProSession.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/se/su/dsv/scipro/SciProSession.java b/src/main/java/se/su/dsv/scipro/SciProSession.java
index a973e241cd..4c7efc0954 100644
--- a/src/main/java/se/su/dsv/scipro/SciProSession.java
+++ b/src/main/java/se/su/dsv/scipro/SciProSession.java
@@ -157,6 +157,7 @@ public class SciProSession extends WebSession {
 			user = userDao.save(user);
 		}
 		//Assign roles
+		iRoles.clear();
 		if(roleDao.isStudent(user)){
 			iRoles.add(new Student());
 		}
@@ -208,7 +209,6 @@ public class SciProSession extends WebSession {
 			return false;
 		logger.info("Currently logged in user: '"+user.getEmailAddress()+"' attempting switch to '"+suUser+"@"+suRealm+"'");
 		if(suUser != null && roleDao.isSysadmin(user)){
-			iRoles.clear();
 			return signInAuthenticatedUser(suUser, suRealm);
 		}else{
 			logger.error("User does not have the privilege to switch user");