authentication - How to know if a user is logged in from another service -
i have php/apache service , meteor on same server. using accounts-ui package. there anyway know in php script, user logged in, given login token (session id?)
this original need: upload profile picture logged in user. simple right? have not found answer after hours of googling.
first solution using html5 file apis send data meteor server , server save image. solution wont work ie9.
second solution trying: using html form upload picture php script (or whatever script, can nodejs script if needed). script save image traditional php script does. thing cannot know if upload request authorized, otherwise can change profile picture of anybody. must add information in upload request , verify them in php code before saving image. thinking sending request php script meteor server need know parameters send , how meteor responses it.
how can achieve second solution or if has solution origin problem great.
thank you.
meteor uses protocol called ddp communicate between client , server. of there isn't php ddp client have use rest type communication method between meteor server , php server.
if feel build php client meteor client, you stuff run meteor.call php scripts , have them subscribe collections. full ddp spec (pre1) can found @ : https://github.com/meteor/meteor/blob/master/packages/livedata/ddp.md
to rest method should use meteor router allow create server side routes. installed via meteorite helps access list of community packages @ [atmosphere.meteor.com].1
sever side js
meteor.router.add('/checklogin', 'post', function() { var userid = this.params.userid; var logintoken = this.params.logintoken; if(userid && logintoken) { return (!!meteor.findone({_id:userid,"services.resume.logintokens.token":logintoken})); } });
you can post request php /checklogin
2 params, 1 userid userid (found meteor.userid()
or localstorage.getitem("meteor.userid")
. other login token found via localstorage.getitem("meteor.logintoken")
on meteor client.
Comments
Post a Comment