Ionic View: $http.get crashing on invalid credentials authentication

Hi,

short version:
I’m having a problem on IonicView, while this problem does not exist on browsers or compiled to Android.
The problem is, that IonicView crashes, if an authentication via http.get is done with invalid credentals (and therefore the server answers with 401).

Long version:
I implemented a custom authentication to a remote rest server using the HttpService and the QService:

constructor(private $q: ng.IQService, public $http: ng.IHttpService){

}

the function for the authentication is called “login”, and accepts as paremeters an object with the user credentials inside:

login = (data: AgrClient.Interfaces.IAuthData) => {
var self = this;
if ((data == undefined)
|| (data.password == undefined)
|| (data.password.length < 1)
|| (data.user == undefined)
|| data.user.length < 1) {

            //invalid login credentials- abort.
            return self.$q.reject();
        }
        console.log("trying to authenticate...");
        
        // data: benutzer:passwort
        return this.$http.get(this.urls.BASE_API + '/auth/login',
            {
                headers: {
                    Authorization: "Basic " + window.btoa(data.user + ":" + data.password)
                }
            }).then((res: any) => {
                console.log("succ1...");
                self.$localStorage.token = res.data.AuthenticationSuccess;
                self.authenticated = true;
                console.debug("Authorization successfull");
                return res;
            }, (res: any) => {
                console.debug("Authorization failed");
                delete self.$localStorage.token;
                self.authenticated = false;
                return self.$q.reject(res);
            }).catch((res) => {
                console.debug("Authorization failed");
                delete self.$localStorage.token;
                self.authenticated = false;
                return self.$q.reject(res);
            });
    }

The authorization works perfect if the credentials are right. If the data.username or data.password is not defined or if it’s length <1 the promise is rejected and works either perfectly.

But if I try to use an invalid credential (so p.r. user not existing on server or wrong password), the server turns back a 401 and IonicView crashes.

I tried to catch the error over adb logwatch:

02-15 10:24:28.064 10230 10230 W System.err: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.Class java.lang.Object.getClass()’ on a null object reference

02-15 10:24:28.074 10230 10230 W System.err: at org.apache.cordova.inappbrowser.InAppBrowser$InAppBrowserClient.onReceivedHttpAuthRequest(InAppBrowser.java:1057)

02-15 10:24:28.074 10230 10230 W System.err: at com.android.webview.chromium.WebViewContentsClientAdapter.onReceivedHttpAuthRequest(WebViewContentsClientAdapter.java:920)

02-15 10:24:28.074 10230 10230 W System.err: at org.chromium.android_webview.AwContents.onReceivedHttpAuthRequest(AwContents.java:2689)

02-15 10:24:28.074 10230 10230 W System.err: at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)

02-15 10:24:28.074 10230 10230 W System.err: at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:41)

02-15 10:24:28.074 10230 10230 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102)

02-15 10:24:28.074 10230 10230 W System.err: at android.os.Looper.loop(Looper.java:148)

02-15 10:24:28.074 10230 10230 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7331)

02-15 10:24:28.074 10230 10230 W System.err: at java.lang.reflect.Method.invoke(Native Method)

02-15 10:24:28.074 10230 10230 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)

02-15 10:24:28.074 10230 10230 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

02-15 10:24:28.074 10230 10230 F chromium: [FATAL:jni_android.cc(236)] Please include Java exception stack in crash report

I have no idea where this exceptions comes from and even searching around on ionic an SO did not help.
Has anyone an idea where this problem could come from?

Thanks and BR
haui

Bump up.
Thanks for any help in advance!

Just getting the same Ionic View App crash on invalid credentials.
Any news?

unfortunately not :confused: