Loopcast / beta

1 stars 0 forks source link

integrate edit user info on client side #111

Closed hems closed 9 years ago

hems commented 9 years ago

Ciao @stefanoortisi

I'm just committing the edit user api on backend and client side ( :

For instance to update genres, you can do

api.loopcast.user.edit( { genres: [ "ambient", "experimental" ] }, function( error, response ) { if( error ) console.error( error ); console.log( response ) } )

For instance to update about, you can do

api.loopcast.user.edit( { about: "about about about" }, function( error, response ) { if( error ) console.error( error ); console.log( response ) } )

You can check the client side API code here: https://github.com/Loopcast/beta/blob/26dd3f636de9e5aedc6e28e571fd0b1d6a337540/src/frontend/scripts/api/loopcast/loopcast.coffee#L91-L102

And the backend here: https://github.com/Loopcast/beta/blob/26dd3f636de9e5aedc6e28e571fd0b1d6a337540/src/routes/api/v1/user/edit.coffee#L34-L55

The code on the backend still quite ugly, as it's the first proof of concept, feel free to edit in order to add more custom_properties, like cover_photo / avatar_url .

We will also have to do some trick with the "social network links", and custom properties like

"social_link_1", "social_link_2", "social_link_3" and so on, so perhaps this ones we will have to always send all together, and clean up the links from the database before inserting all the new ones...

We will figure the details along the way ( :

hems commented 9 years ago

@thomas1602 i just managed to update "user_id" without creating a new user ( :

@stefanoortisi when the user updates "user_id" i believe we should instantly "replace state" for the URL, so the new url is reflected with the new user_id. I think once we get a sucessfull response from the backend we should also update the username variable on the "cookie" variable via client side.

stefanoortisi commented 9 years ago

@hems

I think we should retrieve the complete user data from intercom when the user successfully logs in. https://github.com/Loopcast/beta/blob/development/src/routes/login/facebook.coffee#L48

At the moment we are passing to the successfull.jade view just the bare minimum information https://github.com/Loopcast/beta/blob/development/src/routes/login/successful.coffee#L25-L26

After that, I've been trying to edit the user data calling the api but when I try to edit the bio, i get a 422 http error (Unprocessable Entity).

You can replicate the error by:

You gonna get this 422 error.

Can you have a look on that?

Cheers!

hems commented 9 years ago

@stefanoortisi yes indeed i know there was issues with this function! as i did not finish that task!

i just did enough so you could start figuring out the frontend, i'm now finishing the backend for editing!

regarding retrieving all the information, what actually is happening is when you go to the profile of the user i render the template with full information, so far i don't think we need to retrieve all user info at login!

But if we find a case where that would be the only solution i'm happy to do that, but as a start i would like to expose as less information to javascript as possible, so we make sure all is rendered on the backend ( indexed by google ) and that we can keep the user information as secure as possible.

Obviously this is just the start and we will figure out all the details pretty soon!

hems commented 9 years ago

So here are the properties we are accepting on the backend so far, let me know if i'm missing something.

stefanoortisi commented 9 years ago

Yes, this page should be working now. Cheers!