public Observable < BackendUser > signUpASync ( final SignUpCredentials signInCreds ) { logger . debug ( "signUpASync(" + signInCreds + ")" ) ; try { setLoginState ( LOGGING_IN ) ; return getWebService ( ) . getPublicKeyA ( ) . flatMap ( new Func1 < byte [ ] , Observable < SignUpCredentials > > ( ) { @ Override public Observable < SignUpCredentials > call ( byte [ ] bytes ) { try { PublicKey key = Crypto . pubKeyFromBytes ( bytes ) ; signInCreds . encryptPassword ( key ) ; return Observable . from ( signInCreds ) ; } catch ( Exception e ) { return Observable . error ( e ) ; } } } ) . flatMap ( new Func1 < SignUpCredentials , Observable < ValidCredentials > > ( ) { @ Override public Observable < ValidCredentials > call ( SignUpCredentials o ) { return getWebService ( ) . userSignUpA ( signInCreds ) ; } } ) . map ( new Func1 < ValidCredentials , BackendUser > ( ) { @ Override public BackendUser call ( ValidCredentials validCredentials ) { return setUser ( validCredentials ) ; } } ) . subscribeOn ( Schedulers . io ( ) ) . observeOn ( config . observeOn ( ) ) ; } catch ( Exception e ) { logger . error ( "Failed to signUp(" + signInCreds . getEmailAddress ( ) + ")" , e ) ; return Observable . error ( e ) ; } }
Asyncronously attempt to create user account