Search in sources :

Example 1 with IdentitySet

use of de.tum.in.tumcampusapp.component.tumui.person.model.IdentitySet in project TumCampusApp by TCA-Team.

the class WizNavCheckTokenActivity method onLoadInBackground.

/**
 * Check in background if token has been enabled and get identity for enabling chat.
 */
@Override
protected Integer onLoadInBackground(Void... arg) {
    // Check if token has been enabled
    if (TUMOnlineRequest.checkTokenInactive(this)) {
        if (NetUtils.isConnected(this)) {
            return R.string.token_not_enabled;
        } else {
            return R.string.no_internet_connection;
        }
    } else {
        // Token was activated
        // Get users full name
        TUMOnlineRequest<IdentitySet> request = new TUMOnlineRequest<>(TUMOnlineConst.Companion.getIDENTITY(), this, true);
        Optional<IdentitySet> id = request.fetch();
        if (!id.isPresent()) {
            return R.string.no_rights_to_access_id;
        }
        Identity identity = id.get().getIds().get(0);
        // Save the name to preferences
        Utils.setSetting(this, Const.CHAT_ROOM_DISPLAY_NAME, identity.toString());
        // Save the TUMOnline id to preferences
        Utils.setSetting(this, Const.TUMO_PIDENT_NR, identity.getObfuscated_ids().getStudierende());
        Utils.setSetting(this, Const.TUMO_STUDENT_ID, identity.getObfuscated_ids().getStudierende());
        Utils.setSetting(this, Const.TUMO_EXTERNAL_ID, identity.getObfuscated_ids().getExtern());
        Utils.setSetting(this, Const.TUMO_EMPLOYEE_ID, identity.getObfuscated_ids().getBedienstete());
        return null;
    }
}
Also used : TUMOnlineRequest(de.tum.in.tumcampusapp.api.tumonline.TUMOnlineRequest) IdentitySet(de.tum.in.tumcampusapp.component.tumui.person.model.IdentitySet) Identity(de.tum.in.tumcampusapp.component.tumui.person.model.Identity)

Aggregations

TUMOnlineRequest (de.tum.in.tumcampusapp.api.tumonline.TUMOnlineRequest)1 Identity (de.tum.in.tumcampusapp.component.tumui.person.model.Identity)1 IdentitySet (de.tum.in.tumcampusapp.component.tumui.person.model.IdentitySet)1