Search in sources :

Example 11 with UserIndex

use of org.onebusaway.users.model.UserIndex in project onebusaway-application-modules by camsys.

the class UserDetailsServiceImpl method getOrCreateUserForIndexKey.

@Override
public IndexedUserDetails getOrCreateUserForIndexKey(UserIndexKey key, String credentials, boolean isAnonymous) throws DataAccessException {
    UserIndex userIndex = _userService.getOrCreateUserForIndexKey(key, credentials, isAnonymous);
    setLastAccessTimeForUser(userIndex);
    return new IndexedUserDetailsImpl(_authoritiesService, userIndex);
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex)

Example 12 with UserIndex

use of org.onebusaway.users.model.UserIndex in project onebusaway-application-modules by camsys.

the class CreateUserAction method execute.

@PostConstruct
public void execute() {
    UserIndex userIndex = _userService.getOrCreateUserForUsernameAndPassword(username, password);
    if (userIndex == null)
        throw new IllegalStateException("error creating user");
    if (admin) {
        User user = userIndex.getUser();
        _userService.enableAdminRoleForUser(user, false);
    }
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) User(org.onebusaway.users.model.User) PostConstruct(javax.annotation.PostConstruct)

Example 13 with UserIndex

use of org.onebusaway.users.model.UserIndex in project onebusaway-application-modules by camsys.

the class CurrentUserServiceImpl method handleAddAccount.

@Override
public IndexedUserDetails handleAddAccount(String type, String id, String credentials, boolean isAnonymous) {
    User currentUser = _currentUserStrategy.getCurrentUser(false);
    UserIndexKey key = new UserIndexKey(type, id);
    UserIndex index = _userService.getUserIndexForId(key);
    boolean exists = index != null;
    // New user?
    if (exists) {
        if (currentUser != null) {
            User existingUser = index.getUser();
            _userService.mergeUsers(existingUser, currentUser);
        }
    } else {
        if (currentUser != null)
            index = _userService.addUserIndexToUser(currentUser, key, credentials);
        else
            index = _userService.getOrCreateUserForIndexKey(key, credentials, isAnonymous);
    }
    return new IndexedUserDetailsImpl(_authoritiesService, index);
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User)

Example 14 with UserIndex

use of org.onebusaway.users.model.UserIndex in project onebusaway-application-modules by camsys.

the class CurrentUserServiceImpl method completePhoneNumberRegistration.

@Override
public boolean completePhoneNumberRegistration(String registrationCode) {
    UserIndex userIndex = _currentUserStrategy.getCurrentUserIndex(false);
    if (userIndex == null)
        return false;
    userIndex = _userService.completePhoneNumberRegistration(userIndex, registrationCode);
    if (userIndex == null)
        return false;
    _currentUserStrategy.setCurrentUser(userIndex);
    return true;
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex)

Example 15 with UserIndex

use of org.onebusaway.users.model.UserIndex in project onebusaway-application-modules by camsys.

the class CurrentUserServiceImpl method handleRegistration.

@Override
public IndexedUserDetails handleRegistration(String type, String id, String credentials, boolean isAnonymous) {
    UserIndexKey key = new UserIndexKey(type, id);
    UserIndex index = _userService.getOrCreateUserForIndexKey(key, credentials, isAnonymous);
    User oldUser = _currentUserStrategy.getCurrentUser(false);
    if (oldUser != null && _userService.isAnonymous(oldUser))
        _userService.mergeUsers(oldUser, index.getUser());
    return new IndexedUserDetailsImpl(_authoritiesService, index);
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User)

Aggregations

UserIndex (org.onebusaway.users.model.UserIndex)44 User (org.onebusaway.users.model.User)23 UserIndexKey (org.onebusaway.users.model.UserIndexKey)22 Test (org.junit.Test)9 UserBean (org.onebusaway.users.client.model.UserBean)8 UserRole (org.onebusaway.users.model.UserRole)8 HashSet (java.util.HashSet)6 IOException (java.io.IOException)5 WebApplicationException (javax.ws.rs.WebApplicationException)5 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)5 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)5 UserDetail (org.onebusaway.admin.model.ui.UserDetail)5 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 PostConstruct (javax.annotation.PostConstruct)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Response (javax.ws.rs.core.Response)2 UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)2