use of net.geoprism.account.InvalidUserInviteToken in project geoprism-registry by terraframe.
the class RegistryAccountUtil method inviteCompleteInTrans.
@Transaction
private static void inviteCompleteInTrans(java.lang.String token, String json) {
UserInviteQuery query = new UserInviteQuery(new QueryFactory());
query.WHERE(query.getToken().EQ(token));
OIterator<? extends UserInvite> reqIt = query.getIterator();
UserInvite invite;
if (reqIt.hasNext()) {
invite = reqIt.next();
invite.appLock();
} else {
throw new InvalidUserInviteToken();
}
if ((System.currentTimeMillis() - invite.getStartTime().getTime()) > (GeoprismProperties.getInviteUserTokenExpireTime() * 3600000)) {
throw new InvalidUserInviteToken();
}
JsonObject account = JsonParser.parseString(json).getAsJsonObject();
if (invite.getRoleIds().length() > 0) {
JsonArray array = JsonParser.parseString(invite.getRoleIds()).getAsJsonArray();
List<String> list = new LinkedList<String>();
for (int i = 0; i < array.size(); i++) {
list.add(array.get(i).getAsString());
}
UserInfo.applyUserWithRoles(account, list.toArray(new String[list.size()]), true);
} else {
UserInfo.applyUserWithRoles(account, new String[] {}, true);
}
invite.delete();
logger.info("User [" + account.get(GeoprismUser.USERNAME) + "] has been created via a user invite.");
}
Aggregations