← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22271: set static UID/code on auto-generated user/userrole (on empty db)

 

------------------------------------------------------------
revno: 22271
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2016-03-13 15:13:08 +0700
message:
  set static UID/code on auto-generated user/userrole (on empty db)
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DatabaseAutomaticAccessProvider.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DatabaseAutomaticAccessProvider.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DatabaseAutomaticAccessProvider.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DatabaseAutomaticAccessProvider.java	2016-03-13 08:13:08 +0000
@@ -28,15 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
-
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserCredentials;
 
+import java.util.HashSet;
+
 /**
  * This access provider will put a user with all granted authorities in the database.
- * 
+ *
  * @author Torgeir Lorange Ostby
  */
 public class DatabaseAutomaticAccessProvider
@@ -57,13 +57,18 @@
         String password = "district";
 
         User user = new User();
+        user.setUid( "M5zQapPyTZI" );
+        user.setCode( "admin" );
         user.setFirstName( username );
         user.setSurname( username );
 
         userService.addUser( user );
 
         UserAuthorityGroup userAuthorityGroup = new UserAuthorityGroup();
+        userAuthorityGroup.setUid( "yrB6vc5Ip3r" );
+        userAuthorityGroup.setCode( "Superuser" );
         userAuthorityGroup.setName( "Superuser" );
+        userAuthorityGroup.setDescription( "Superuser" );
 
         userAuthorityGroup.setAuthorities( new HashSet<>( getAuthorities() ) );
 
@@ -75,7 +80,6 @@
         userCredentials.getUserAuthorityGroups().add( userAuthorityGroup );
 
         userService.encodeAndSetPassword( userCredentials, password );
-
         userService.addUserCredentials( userCredentials );
     }