Nikola Brežnjak blog - Tackling software development with a dose of humor
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Home
Daily Thoughts
Ionic
Stack Overflow
Books
About me
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Nikola Brežnjak blog - Tackling software development with a dose of humor
Books

The art of being unmistakable – Srinivas Rao

My notes from (currently) free book The Art of Being Unmistakable: A Collection of Essays About Making a Dent in The Universe by Srinivas Rao, which I rated  4/5 on my Shelfari account.

What if you decided to be the one who creates for the joy of creating, nothing more?!

To experience something new, we have to let go of what’s old. We have to remain calm in the face of setbacks.

My greatest sin was to waste my life believing that I wasn’t capable of something more.

How long are you willing to act like a pro without any of the external rewards that come with it?

If you try to miomic, copy er emulate anybody else, at best you will be a pale imitation.

The only way to really stand out online is to be honest.

None of these things define you as a person: Your education The size of your bank account Your job title Your failures Your successes And sadly, we let so many of these things rule our lives. Obsession with crossing off the checkboxes of society’s life plan leads to little other than therapy, midlife crises, and depression.

Worrying about what other people think is a jail of our own creation, and the irony of it is those people are in the same jail with us.

The “No bullshit” version of who you are can work with a compass. Your ego needs a map because it does not quite understand the wise words of Paul Jarvis, “Nobody is successful because they took somebody else’s roadmap and copied it.

To become truly unmistakable I have to be willing to ditch the map, travel without a guidebook, and see where it leads me.

https://twitter.com/HitmanHR/status/671227308649353216

Ionic, Stack Overflow

Firebase $authWithOAuthRedirect doesn’t call $onAuth without page refresh

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m in the top All time answerers list.

I actually asked this question myself:

I have a simple Firebase Facebook OAuth login set like below by following the official tutorial for the Ionic Firebase Facebook login.

The problem is that once I click on the login with Facebook button, I get redirected to Facebook, I log in, and I get redirected back to my app. However, the problem is that I stay in the login page. Strange thing is that if I physically refresh my browser (testing with ionic serve) by pressing F5 the onAuth triggers and I get redirected to the Items page. If I don’t refresh the browser, onAuthdoesn’t get called.

Did someone have this issue? How did you solve it?

Please note that yes, I did my research (and am slightly starting to lose it), but can’t get it to work. I searched SO, tried with $timeout from google groups, tried to call $scope.$apply(), but all to no avail – so please help me figure out where I’m doing it wrong?

.controller('AppCtrl', function($scope, Items, Auth, $state, $ionicHistory) {
    $scope.login = function(provider) {
        Auth.$authWithOAuthRedirect(provider).then(function(authData) {

        }).catch(function(error) {
            if (error.code === "TRANSPORT_UNAVAILABLE") {
                Auth.$authWithOAuthPopup(provider).then(function(authData) {
                    
                });
            } else {
                console.log(error);
            }
        });
    };

    $scope.logout = function() {
        Auth.$unauth();
        $scope.authData = null;

        $window.location.reload(true);
    };

    Auth.$onAuth(function(authData) {
        if (authData === null) {
            console.log("Not logged in yet");
            $state.go('app.login');
        } else {
            console.log("Logged in as", authData.uid);
            
            $ionicHistory.nextViewOptions({
                disableBack: true
              });
            $state.go('app.items');
        }
        $scope.authData = authData; // This will display the user's name in our view
    });
})
<ion-view view-title="Members area">
    <ion-content padding="true">
        <div ng-if="!authData">
            <button class="button button-positive button-block" ng-click="login('facebook')">Log In with Facebook</button>  
        </div>       
        
        <div ng-if="authData.facebook">
            <div class="card">
                <div class="item item-text-wrap">Hello {{authData.facebook.displayName}}!</div>                
            </div>

            <button class="button button-assertive button-block" ng-click="logout()">Log out</button>
        </div>        

    </ion-content>
</ion-view>

edit: I sort of solved it by using $timeout:

$timeout(function(){
    Auth.$onAuth(function(authData) {
        if (authData === null) {
            console.log("Not logged in yet");
            $state.go('app.login');
        } else {
            console.log("Logged in as", authData.uid);

            $ionicHistory.nextViewOptions({
                disableBack: true
              });
            $state.go('app.items');
        }
        $scope.authData = authData; // This will display the user's name in our view
    });
}, 3000);

However, this just feels wrong (mildly put), and there has to be a better way, so please suggest one. Also, I noticed that the whopping 3second delay is barely enough (few of the resources I found suggested 500ms would be enough, but in my case, that’s not the case).

Answer, from user mhartington, was:

Posted on the github issues, but will reply here as well.

This only happens in the browser using $authWithOAuthRedirect. The example was intended for cordova apps, so this really shouldn’t be an issue.

But if you really need it, you could just skip the redirect and use a popup.

Auth.$authWithOAuthPopup(authMethod).then(function(authData) {
      console.dir(authData);
    });

https://twitter.com/HitmanHR/status/671222279121076224

Books

Free ebook: The Universe doesn’t give a flying fuck about you – Johnny Truant

My notes from (currently) free book The Universe Doesn’t Give a Flying Fuck About You (Epic series Book 1) by Johnny Truant, which I rated  4/5 on my Shelfari account. Actually, the whole series (4 books) is free currently, so you may wanna rush your download 😉

If you knew how small you are and how short a time you have to do what you can, you wouldn’t waste time watching five fucking hours of TV a day.

Stop being a pussy and go do something amazing!

It doesn’t matter what you’ve done. What matters is what you do.

It means that even though the universe doesn’t care enough to give you what you want, it doesn’t care enough to stop you from having it, either. So embrace that anarchy, and take those things for yourself.

Just do it. Claim it. Stop waiting for permission.

Fucking hell. Stop whining and just be it already. Be fucking awesome.

Your life is a one-way train, and any second you waste is a second lost forever.

There’s a drinking game in Heaven, where angels do a shot every time humans invest ‘for the long term.

I heard that God watches jewelry commercials and LOL’s when they say that diamonds are forever.

https://twitter.com/HitmanHR/status/671216342465437696

Recent posts

  • When espanso Breaks on Long Replacement Strings (and How to Fix It)
  • 2024 Top Author on dev.to
  • Hara hachi bun me
  • Discipline is also a talent
  • Play for the fun of it

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (36)
  • Daily Thoughts (78)
  • Go (3)
  • iOS (5)
  • JavaScript (128)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (3)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (78)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (41)
  • Servers (8)
    • Heroku (1)
    • Linux (3)
  • Stack Overflow (81)
  • Unity3D (9)
  • Windows (8)
    • C# (2)
    • WPF (3)
  • Wordpress (2)

"There's no short-term solution for a long-term result." ~ Greg Plitt

"Everything around you that you call life was made up by people that were no smarter than you." ~ S. Jobs

"Hard work beats talent when talent doesn't work hard." ~ Tim Notke

© since 2016 - Nikola Brežnjak