how to modify my profile according to a user's ID In laravel + Vue

1

Hi, I'm new to laravel And I have a problem when it comes to obtaining the data according to each Account. I do not know how to send the unique ID of my account to a Vue + axios so axios automatically shows my information according to the account

(the information load works fine but only if it is static, in this example I put the 2, etc. and it loads well)

var url = 'conf/2' // le he pasado el 2 de manera estatica

a small part of my code

getPerfil:function(){
			var url = 'conf/2';
			axios.get(url).then(response=>{
				this.info = response.data
			});
		},

And right up there, everything is perfect, it loads information but not dynamically according to each Account.

Another problem that I have had, I have noticed is that I can modify any account just by changing the ID. which it's If this is a security problem because anyone could insert information in x account.

    
asked by Alex Burke Cooper 26.03.2018 в 20:12
source

1 answer

1

Assuming that the user has already logged in, and that he is the current user, you could use the Auth facade or the auth () helper to get the user's id:

getPerfil:function(){
        var url = 'conf/' + '{{auth()->user()->id}}';
        axios.get(url).then(response=>{
            this.info = response.data
        });
    },
    
answered by 27.03.2018 / 03:35
source