Uploaded image for project: 'Agorava'
  1. Agorava
  2. AGOVA-53

OAuthComplete Event is unstable as a User facing API

    Details

      Description

      To be able to @Observe OAuthComplete is a nice hook for the User to fetch the UserProfile info when a auth is complete, in a modular fashion.

      But in the current impl, this API is unstable. The OAuthServices use the same API to register the UserProfile in the first place;

      TwitterUserServiceImpl

          public void initMyProfile(@Observes @Twitter OAuthComplete oauthComplete) {
              //     log.debug("**** Initializing Twitter profile ****");
              if (oauthComplete.getStatus() == SocialEvent.Status.SUCCESS)
                  oauthComplete.getEventData().setUserProfile(getUserProfile());
          }
      

      In CDI 1.0 there is no way to Order the Observers, so depending on which Observer that happened to run first; build-in TwitterUserServiceImpl or my Observer, the following might cause NullPointerException

      public void registerUser(@Observes SocialEvent<OAuthSession> event) {
          if(event.getStatus() == SocialEvent.Status.SUCCESS) {
              event.getEventData().getUserProfile().getFullName(); // UserProfile is null
          }
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                antoinesabot-durand Antoine Sabot-Durand
                Reporter:
                aslak Aslak Knutsen
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: