Users Class
Users plugin's front end code
Item Index
Methods
- authenticate
- facebookDialog
- get
- getContacts static
- getLabels static
- hint static
- hint static
- initFacebook
- initFacebook.ready
- loggedInUserId static
- login
- logout
- prompt
- scope
- setIdentifier
- User
Properties
Methods
authenticate
-
platform
-
onSuccess
-
onCancel
-
[options]
Authenticates this session with a given platform
Parameters:
-
platform
StringCurrently only supports "facebook", "ios" or "android"
-
onSuccess
FunctionCalled if the user successfully authenticates with the platform, or was already authenticated. It is passed the user information if the user changed.
-
onCancel
FunctionCalled if the authentication was canceled.
-
[options]
Object optionalobject of parameters for authentication function
-
[prompt=null]
Function | Boolean optionalwhich shows the usual prompt unless it was already rejected once. Can be false, in which case the user is never prompted and the authentication just happens. Can be true, in which case the usual prompt is shown even if it was rejected before. Can be a function with an onSuccess and onCancel callback, in which case it's used as a prompt.
-
[force]
Boolean optionalforces the getLoginStatus to refresh its status
-
[appId=Q.info.app]
String optionalOnly needed if you have multiple apps on platform
-
facebookDialog
-
[options]
Makes a dialog that resembles a facebook dialog
Parameters:
-
[options]
Object optionalA hash of options, that can include:
-
[title]
String optionalDialog title.
-
[content]
String optionalDialog content, can be plain text or some html.
-
[buttons]
Array optionalArray of object containing fields:
-
[position]
Object optionalHash of x/y coordinates. By default (or if null) dialog is centered on the screen.
-
[shadow]
Boolean optionalWhether to make a full screen shadow behind the dialog, making other elements on the page inaccessible.
-
get
-
userId
-
callback
Users batch getter.
getContacts
-
userId
-
[labels]
-
[contactUserIds]
-
callback
Get a user's contacts
getLabels
-
userId
-
[prefix]
-
callback
Get a user's contact labels
hint
-
key
-
elementsOrPoints
-
[options.src]
-
[options.hotspot={x:0.5,y:0.3}]
-
[options.width="200px"]
-
[options.height="200px"]
-
[options.zIndex=99999]
-
[option.dontStopBeforeShown=false]
-
[options.dontRemove=false]
-
[options.audio.src]
-
[options.audio.from=0]
-
[options.audio.until]
-
[options.audio.removeAfterPlaying]
-
[options.show.delay=500]
-
[options.show.initialScale=10]
-
[options.show.duration=500]
-
[options.show.ease=Q.Animation.ease.smooth]
-
[options.hide.duration=500]
-
[options.hide.ease=Q.Animation.ease.smooth]
Places a hint to click or tap on the screen
Parameters:
-
key
StringA key to ensure the hint appears only the first time for each user. Check Users.hinted to see if this has happened.
-
elementsOrPoints
Element | Object | ArrayIndicates where to display the hint. A point should contain properties "x" and "y". Can also be an array of elements or points.
-
[options.src]
String optionalthe url of the hint pointer image
-
[options.hotspot={x:0.5,y:0.3}]
Point optional"x" and "y" represent the location of the hotspot within the image, using fractions between 0 and 1
-
[options.width="200px"]
String optional -
[options.height="200px"]
String optional -
[options.zIndex=99999]
Integer optional -
[option.dontStopBeforeShown=false]
Boolean optionalDon't let Q.Pointer.stopHints stop this hint before it's shown.
-
[options.dontRemove=false]
Boolean optionalPass true to keep current hints displayed
-
[options.audio.src]
String optionalCan be used to play an audio file.
-
[options.audio.from=0]
String optionalNumber of seconds inside the audio to start playing the audio from. Make sure audio is longer than this.
-
[options.audio.until]
String optionalNumber of seconds inside the audio to play the audio until. Make sure audio is longer than this.
-
[options.audio.removeAfterPlaying]
String optionalWhether to remove the audio object after playing
-
[options.show.delay=500]
Integer optionalHow long to wait after the function call (or after audio file has loaded and starts playing, if one was specified) before showing the hint animation
-
[options.show.initialScale=10]
Integer optionalThe initial scale of the hint pointer image in the show animation
-
[options.show.duration=500]
Integer optionalThe duration of the hint show animation
-
[options.show.ease=Q.Animation.ease.smooth]
Function optional -
[options.hide.duration=500]
Integer optionalThe duration of the hint hide animation
-
[options.hide.ease=Q.Animation.ease.smooth]
Function optional
hint
-
forType
-
forId
-
[value=1]
-
elementOrPoint
-
[options]
Votes for something
Parameters:
-
forType
StringThe type of thing to vote for
-
forId
StringThe id of thing to vote for
-
[value=1]
Number optionalthe value the user has voted for, such as a rating etc.
-
elementOrPoint
Element | ObjectIndicates where to display the hint. A point should contain properties "x" and "y".
-
[options]
Object optionalpossible options, which can include:
Returns:
Returns true if the hint with will be shown, or false if a hint with this key was already shown before.
-
icon
-
[basename=40]
Calculate the url of a user's icon
Parameters:
Returns:
the url
initFacebook
-
callback
-
options
Initialize facebook by adding FB script and running FB.init(). Ensures that this is done only once
-
[size=40]
Calculate the url of a user's icon
Parameters:
-
[size=40]
Number optionalthe size of the icon to render.
Returns:
the url
initFacebook.ready
-
[appId=Q.info.app]
-
callback
You can wrap all uses of FB object with this
loggedInUserId
()
String
static
A shorthand way to get the id of the logged-in user, if any
Returns:
the id of the logged-in user, or the empty string if not logged in
login
-
[options]
Log the user in
Parameters:
-
[options]
Object optionalYou can pass several options here
-
[onSuccess]
Q.Event optionalevent that occurs when login or authentication "using" a platform is successful. It is passed (user, options, result, used) where user is the Users.User object (null if it was unchanged), options were the options used in the call to Users.login, result is one of "registered", "adopted", "connected" or "authorized" (see Users::authenticate) and 'used' is "native", or the name of the platform used, such as "facebook".
-
[onCancel]
Function optionalevent that occurs when login or authentication "using" a platform was canceled.
-
[onResult]
Function optionalevent that occurs before either onSuccess, onCancel, or onRequireComplete
-
[successUrl]
String optionalIf the default onSuccess implementation is used, the browser is redirected here. Defaults to Q.uris[Q.info.app+'/home']
-
[accountStatusUrl]
String optionalif passed, this URL is hit to determine if the account is complete
-
[onRequireComplete]
Function optionalfunction to call if the user logged in but account is incomplete. It is passed the user information as well as the response from hitting accountStatusUrl
-
[using]
String optionalcan be "native", "facebook" or "native,facebook"
-
[tryQuietly]
Boolean optionalif true, this is same as Users.authenticate, with platform = "using" option
-
[unlessLoggedIn]
Boolean optionalif true, this only proceeds with the login flow if the user isn't already logged in. Can be combined with tryQuietly option.
-
[scope=['email','public_profile','user_friends']
Array optionalpermissions to request from the authentication platform
-
[identifierType="email,mobile"]
String optionalthe type of the identifier, which could be "mobile" or "email" or "email,mobile"
-
[appIds={}]
Object optionalCan be used to set custom {platform: appId} pairs
-
logout
-
[options]
Log the user out
Parameters:
-
[options]
Object optionalYou can pass several options here It is passed the user information if the user changed.
-
[url]
String optionalthe URL to hit to log out. You should usually not change this.
-
[using]
String optionalcan be "native" or "native,facebook" to log out of both
-
[onSuccess]
Q.Event optionalevent that occurs when logout is successful.
-
[welcomeUrl]
String optionalthe URL of the page to show on a successful logout
-
prompt
-
platform
-
uid
-
authCallback
-
cancelCallback
-
options
-
options
Used when platform user is logged in to platform but not to app. Shows prompt asking if user wants to log in to the app as platform user.
Parameters:
-
platform
StringFor now, only "facebook" is supported
-
uid
StringThe platform uid
-
authCallback
Function, this function will be called after user authentication
-
cancelCallback
Function, this function will be called if user closed social platform login window
-
options
Object-
[dialogContainer=document.body]
DOMElement optionalparam with jQuery identifier of dialog container
-
-
options
Object-
[=Q.info.app]
String optionalOnly needed if you have multiple apps on platform
-
scope
-
platform
-
callback
-
options
Check permissions granted by platform. Currently only facebook is supported.
Parameters:
-
platform
StringFor now, only "facebook" is supported
-
callback
Functionthis function will be called after getting permissions from the external platform. The first parameter is the raw data returned. The second parameter is an array of Boolean corresponding to the scope names in options.check, indicating whether they were granted. Callback parameter could be null or response object from social platform
-
options
Object
setIdentifier
-
[options]
Displays a dialog allowing the user to set a different identifier (email address, mobile number, etc.) as their primary login method
Parameters:
-
[options]
Object optionalYou can pass several options here It is passed the user information if the user changed.
-
[identifierType]
String optionalthe type of the identifier, which could be "mobile" or "email" or "email,mobile"
-
[userId]
String optionalYou can set this to the id of a user in the database who doesn't have any email or mobile number set yet. This can happen if the user was e.g. invited via a printed invitation and lost it, and allows someone to help set up the first identifier for that user.
-
[onSuccess]
Q.Event optionalevent that occurs on success
-
[onCancel]
Q.Event optionalevent that occurs if the dialog is canceled
-
[onResult]
Function optionalevent that occurs before either onSuccess or onCancel
-
User
-
fields
Constructs a user from fields, which are typically returned from the server.
Parameters:
-
fields
String
Properties
Events
onDevice
This event is fired when a device has been registered for a logged-in user.
Event Payload:
-
device
ObjectSee Users_Device
onError
This event is fired if an error occurs in any Users function
Event Payload:
-
err
Mixed -
err2
Mixed