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

23rd
Jun 2016
Allan Alvarez Ortiz
@flick36
Jun 23 2016 01:35
Well if it's the one that it's generated with the artisan command, it should work by default O.o, can you check if the function in the DialogController, has this function:
```
cancel() {
        this.DialogService.cancel();
    }
and of course the DialosService has to be injected in that controller, and in your html template, use it in any button as you mentioned vm.cancel() now everytime you create new components, dialogs etc with the artisan commands, you have tu run gulp again, cause they're not being watched when newlye created
Mark Kevin Besinga
@besingamkb
Jun 23 2016 01:41

here's what i do .. I injected DialogService on my components class

constructor($document, DialogService){
        'ngInject';
        this.DialogService = DialogService;
    }

and then this

showEditDialog(ev, project) {        
        return this.DialogService.fromTemplate('edit-project', {
            parent: angular.element(this.document.body),
            clickOutsideToClose:true
        });
    }

to open the dialog

here is the edit-project.dialog.js
export class EditProjectController{
    constructor(DialogService){
        'ngInject';

        this.DialogService = DialogService;
        console.log("yow");
    }

    save(){
        //Logic here
        this.DialogService.hide();
    }

    cancel(){
        this.DialogService.cancel();
    }
}
do I need to import the EditProjectController on my component class?
Mark Kevin Besinga
@besingamkb
Jun 23 2016 01:49

or maybe it is conflict since I create a dialog without using the generator? i have injected $mdDialog on constructor???

OKAY. here my real component class constructor.

constructor($mdDialog, $mdMedia, $mdToast, API, $state, $document, DialogService){
        'ngInject';

        this.mdDialog = $mdDialog;
        this.mdMedia = $mdMedia;
        this.mdToast = $mdToast;
        this.API = API;
        this.document = $document;

        //DIALOG SERVICES
        this.DialogService = DialogService;

        this.state = $state;
    }
Allan Alvarez Ortiz
@flick36
Jun 23 2016 02:49
and your html? it's the default one? or have you altered it?
Mark Kevin Besinga
@besingamkb
Jun 23 2016 02:51
i didnt alter the html of the generated dialog
Allan Alvarez Ortiz
@flick36
Jun 23 2016 02:52
ok and what's the exact error it throws you? or it just doesnt do anything? if you put a console.log() in the cancel fucntion does it shows?
Mark Kevin Besinga
@besingamkb
Jun 23 2016 02:55
console.log not firing.
i dont have errors on console. i only got warning but i think it is not related
Allan Alvarez Ortiz
@flick36
Jun 23 2016 03:00
ok that's definitly weird :S i think you are not calling vm.cancel() where you think you are calling it amm can you record a gif or show me full code? of the compnents you're using the dialog and the dialog itself? both html and js of both, maybe email me with those file attach if you want
Mark Kevin Besinga
@besingamkb
Jun 23 2016 03:00
okay thanks. i will email it
Feyyaz Esatoğlu
@feyyazesat
Jun 23 2016 07:01
hi all, I'm stuck somewhere I need some ideas.
I'm trying to login user with steam, it is basicall steam login.
steam only provides OpenId login
Th steps exactly looks like following :
when some one click the login with steam button, it redirects to the steam login page,
the authorization is handling by steam, so there is no chance to put a custom login form.
when user authorized in steam, then they just return the url which we gave when sending user to the login page.
so it is a bit messy to connect this authentication system with jwt.
Feyyaz Esatoğlu
@feyyazesat
Jun 23 2016 07:06
I have a solution about that, but in backend side I don't know how to handle.
I will send dynamic return_url, which like this https://mywebsite.com/#/steam-auth and in this url I will grab several steam information then I will create on the fly random password for the user and steamuserId@mywebsite.com as an email address.
I know steamUserId is unique. so I will send a registration request if user is not already registered.
if registered I will just log in user with these information, but password is a bit tricky.
I should find a way to login user without password, but it would be safe against to MITM attacks etc.
referral checks is not so safe.
so do you have any different ideas how to login user with this system ?
Jad Joubran
@jadjoubran
Jun 23 2016 07:49
@feyyazesat are you using satellizer to help you with the auth?
it is already built into the project, so you can easily configure openId as per their documentation
Feyyaz Esatoğlu
@feyyazesat
Jun 23 2016 07:50
@jadjoubran actually, I couldn't find the openid usage in their documentation, openId is built on top of oauth2.0 but still it is not oauth2, and the config for oauth2.0 is not satisfied by steam.
I never worked with openId but maybe they help
Feyyaz Esatoğlu
@feyyazesat
Jun 23 2016 07:59
sahat/satellizer#160
according to the question it is exactly my condition, according to my condition, I don't make authorization actually I'm just authenticate a person if steam says yes this user is a valid user and these are the user information.
it is a bit silly difference but thanks in anyway @jadjoubran . Lastly I would like to do something like this what is your ideas ?
I can properly authenticate user on steam on backend side. I will put an ajax point there.
let make the endpoint as, /api/steam-auth
This message was deleted
I would put a angular endpoint say : /#/steam-auth
and it would be the return url after authenticate on steam.
then I will get the incoming get parameters from steam, and will make an ajax request to the /api/steam-auth
backend will take care other steps of openid communication, when it gets the openid.signed it will create a jwt token and give as a response to the angular.
Feyyaz Esatoğlu
@feyyazesat
Jun 23 2016 08:04
then angular will just make a $auth.setToken()
it is my use case now is this make any sense ? do you see any down points here ?
Feyyaz Esatoğlu
@feyyazesat
Jun 23 2016 13:07
very long and annoying challenging I solved the problem.
    $urlRouterProvider
        .otherwise('/')
        .when('/steam-auth{params:.*}', [
            '$state',
            '$location',
            'API',
            '$auth',
            'LoginFormControllerService',
            function ($state, $location, API, $auth, LoginFormControllerService) {
                let qs = $location.search();

                if ( !(qs.hasOwnProperty('openid.assoc_handle') && qs.hasOwnProperty('openid.signed') && qs.hasOwnProperty('openid.sig')) ) {
                    return $state.go('app.login');
                }

                let $steamAuthAPI = API.one('auth/steam-auth');

                if ($auth.isAuthenticated()) {
                    $steamAuthAPI = API.one('steam-auth');
                }

                $steamAuthAPI
                    .get(qs)
                    .then((response) => {
                        $auth.setToken(response);
                     })
                    .catch(LoginFormControllerService.failedLogin.bind(LoginFormControllerService));

                return $state.go('app.login');
            }
        ]);
I put the return url as /#/steam-auth
when steam returns me, I checked the required get parameters if everything is OK I'm just make an api call to a custom auth endpoint, there is 2 endpoints one is for non jwt authenticated, one is jwt authenticated.
when request hit the jwt authenticated endpoint it basically merge user then recreate jwt, the other one creates new user and new jwt token and returns as a response, this authenticates angular app then redirects to landing page.
Mark Kevin Besinga
@besingamkb
Jun 23 2016 14:02
@flick36 i know whats the problem on my dialog. on my services/dialog.service.js i dont see the cancel() and the ng:dialog generate this
    cancel(){
        this.DialogService.hide();
    }
and I look on the github repo and yes cancel() in dialog service exist. hmm maybe i got the outdated branch?
is there a way to update my working file? i also check other function. and I also see changes
Mark Kevin Besinga
@besingamkb
Jun 23 2016 14:09
or maybe I am using an updated generator that is not compatible on my laravel-angular version?
Mark Kevin Besinga
@besingamkb
Jun 23 2016 14:26
but in order for me to make it work I need to import the dialog controller to the component and add the controller and controllerAs options.
Allan Alvarez Ortiz
@flick36
Jun 23 2016 15:15
Yes i mention that a couple of sometimes on github
There's no way to automatically update your branch, only way i can thinkg right now it's to create a new folder with the newest version available, and compare the folder for changes if you are on windows a program i recommend to do that is: WinMerge of course youll have multiple different filez but focus only on the core ones, not the ones you have made, another way to do so, it's to manually see and modify the commits from the date you download the starter till now
Mark Kevin Besinga
@besingamkb
Jun 23 2016 15:20
@flick36 this is noted. thanks.