ionic-team / ionic2-starter-aws

Ionic + AWS MobileHub Starter Project
235 stars 47 forks source link

User provider authenticateUser callbacks end up with the wrong "this" #28

Closed NimaiMalle closed 7 years ago

NimaiMalle commented 7 years ago

in src/providers/user.ts, I had to change the way that the callback functions are declared in order to get the a this which refers to a User object, or else the call to this.isAuthenticated fails.

-        'onSuccess': (result) => {
+        'onSuccess': function(result) {
-        'onFailure': (err) => {
+        'onFailure': function(err) {

$ ionic info


global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 2.0.0
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : browser 4.1.0
    Ionic Framework                 : ionic-angular 3.5.0

System:

    Node       : v7.10.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 4.2.0```
NimaiMalle commented 7 years ago

There was already a Pull Request to fix this: "Proper syntax for onSuccess and onFailure callbacks"