device user mapping in mobile first platform 7.1 console while log in through adapterbased auhentication

112 Views Asked by At

I am trying to create a login module from the tutorial and will be using the login user id as target in my next step :sent_EventBased_Push_notification

https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/authentication-security/adapter-based-authentication/adapter-based-authentication-native-android-applications/

Done no changes just downloaded those sample project from github and run then in mfp and android studio as it is.And they did work wonderfully.

But in mobilefirst console though I saw the the device got registered there is no user id against it..What I mean is I am using a nexus4 to login and login id s 'my-phn-no'.So user Id should be 'my-phn-no'.

below I am pasting my AuthAdapter-impl.js [same as eg.]

function onAuthRequired(headers, errorMessage){
   errorMessage = errorMessage ? errorMessage : null;

   return {
    authStatus: "credentialsRequired",
    errorMessage: errorMessage
};
}

function submitAuthentication(username, password){
if (username==="8907870678" && password === "password"){

    var userIdentity = {
            userId: username,
            displayName: username, 
            attributes: {
                foo: "bar"
            }
    };
    //WL.Server.sendMessage("Hello", "hi,gd mg")
    WL.Server.setActiveUser("AuthRealm", userIdentity);

    return { 
        authStatus: "complete" 
    };
    }

   return onAuthRequired(null, "Invalid login credentials");
  }

 function getSecretData(){
    return {
    secretData: "12345 changed for trial"
   };
  }

 function onLogout(){
    WL.Logger.debug("Logged out");
}

Can you please point out the part I am missing/how do I implement it. Thank you in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

I tried the same code in SIT environment where it have the actual product installed MFP 7.1 . It worked perfectly . I guess there is some thing going wrong in my eclipse plugin.