These are chat archives for jadjoubran/laravel5-angular-material-starter

9th
Jun 2016
Jad Joubran
@jadjoubran
Jun 09 2016 08:32
@besingamkb have you got sample code?
normally you'd just console.log() there's nothing special about it
Elvis Magagula
@ElvisMagagula
Jun 09 2016 08:35
or $log.log()
What are you trying to console log?
Mark Kevin Besinga
@besingamkb
Jun 09 2016 11:58

oh yeah. it's kinda weird. i got an error yesterday on gulp that console.log is not possible. i must try angular log. but it wont work.

anyways. console.log is really working. i'm still not sure what cause of my error yesterday

Jad Joubran
@jadjoubran
Jun 09 2016 13:08
@besingamkb the error in gulp is coming from eslint
this is not technically an error, this is just a code quality error
you can configure it in your .eslintrc file
Mark Kevin Besinga
@besingamkb
Jun 09 2016 13:12
thanks again jad.
Elvis Magagula
@ElvisMagagula
Jun 09 2016 13:13
or just use $log.log() instead of console.log() :)
Mark Kevin Besinga
@besingamkb
Jun 09 2016 13:16
thanks @ElvisMagagula i'm really new on lot of things here. anyways. where can I control the authenticated user? for example. checking if there is a user. then don't show the login page.? can you point out the answer or just the documentation of it? i can't find it on the l5ams docs
Elvis Magagula
@ElvisMagagula
Jun 09 2016 13:19
Angular or laravel side? and what version of laravel angular are you on?
Mark Kevin Besinga
@besingamkb
Jun 09 2016 13:21
hmm. i think on angular side. cause the laravel only serve the index right? and what I am thinking that this JWT is handling it (im not sure im also new to this). i just started yesterday and i think i have the latest version
its version 3.2
Elvis Magagula
@ElvisMagagula
Jun 09 2016 13:25
this is how im using it...
.config(['$middlewareProvider', function($middlewareProvider) {
            $middlewareProvider.map({
                'authenticated_redirect': ['Auth', function Authenticate(Auth) {
                    var request = this;
                    if(Auth.isAuth()){
                        request.redirectTo('dashboard');
                    } else {
                        return request.next();
                    }
                }]
            });
        }])
But that for a different senario
Mark Kevin Besinga
@besingamkb
Jun 09 2016 13:30
can I do this on logincontroller?
Elvis Magagula
@ElvisMagagula
Jun 09 2016 13:35
You can but your view will get rendered...if you are ok with the flickering and then redirecting the user then go for it.
Mark Kevin Besinga
@besingamkb
Jun 09 2016 13:35

it works i do this


        if (this.$auth.isAuthenticated()) {
            $state.go('app.projects');
        }

the problem now is the login link on menu

yes your right. the form just show and then redirect.
Elvis Magagula
@ElvisMagagula
Jun 09 2016 13:37
        api.headers = function(_data) {
            if (_data.status === 422) {
                for (var error in _data.data.errors) {
                    $log.error(_data.data.errors[error][0]);
                }
            }
            if (_data.status === 401 || status === 403) {
                handleNotAuthenticated();
            }
        };

        var handleNotAuthenticated = function() {
            // 
            $state.go('yourState');
        };
Thats what I did in one of my projects
Didnt like the redirecting
Mark Kevin Besinga
@besingamkb
Jun 09 2016 14:36
this is $scope right?
Jad Joubran
@jadjoubran
Jun 09 2016 15:45
@besingamkb Kind of but not really => here's a tutorial https://toddmotto.com/digging-into-angulars-controller-as-syntax/