Gigya - complete registration for an auto-generated account - javascript

Newbie to gigya. I have been trying to identify how can I achieve complete registration in my web application for an account that is generated using gigya REST api with an auto-generated details. I have the UID for that account, using which I can retrieve the user details.
My questions are:
Is it possible to complete the registration for that account(auto-generated) using the Complete Registration screen set?
If so, how can I achieve the profile completion?

Screen-Sets are client-side, so, there is no way to use the Complete Registration screen inside a REST implementation.
Three possible solutions are:
If you have the data: Include all the necessary data properties in the call to accounts.register.
If you have the data: After registering the user, using the UID call accounts.setAccountInfo and add the necessary data properties.
If you don't have the data: Don't do anything via REST to complete the registration info (and leave it in 'Pending' state setting finalizeRegistration: false in the accounts.register call. This will cause the API to return "errorCode": 206001, "errorMessage": "Account Pending Registration"). Then add the screen-sets to your page/app and when the user attempts to login, any required information that is missing will need to be provided via the Complete Registration screen, which will automatically fire and prompt the user for this data and then finalize the registration.

#sadiqmc could you explain a little bit about what you're trying to do? What's the flow that you're trying to accomplish?
Edit:
As per your flow, you probably shouldn't use the Update Profile screen to let the user change their info, as the auto-generated content will be pre populated and will confuse the user.
Since you already have the UID, you can build a generic form to collect the user's data and then update the account using setAccountInfo.

Related

How to login a user using firebase authentication

I'm currently using firebase-admin to create a web Dashboard with node.js as a backend which will have multiple users and those users have user specific data in my database, note that I need them to be able to delete or add stuff to the database as well, I've managed to add new users to Autentication using firebase.auth().createUser() programmatically, but how would one go about logging in a user, and then from there controlling which uid is logged in and displaying his data (giving him access to the correct data, obviously don't want him messing with someone elses data).
I know this might seem like a really newbie question, and it probably is, but firebase docs always get me confused for some reason. Any tips? I'd greatly appreciate.
Any questions don't hesitate.
To login a new user, try this:
firebase.auth().signInWithEmailAndPassword(email, password)
this returns a Firebase.Promise which you can use to track the operation progress. If successful, it will return the corresponding Firebase.User object.
From there, the logged-in user will also be available in the firebase.auth().currentUser property. You can then use the user's uid property as a key for his JSON branch on the database.

How can I keep both users tables "synchronized" using BackAnd?

I'm good with registering users, login, etc.
Now I'm getting into modifying users with:
this.backand.object.update('users', user.userId, user)
but I can see that only my table gets modified, while I'll also need to modify the "Registered Users" table existing in "Security & Auth > Registered Users".
I understand I might need to create a custom action...maybe "Before Update"? ...but I can't find documentation on how to modify that specific table (via API or via BackAnd actions).
Thank you.
thanks for using Backand! We don't offer any methods via the SDK to update the registered users. You can use the HTTP object to send a call to the back-end's REST API directly, hitting the same URL that the SDK requests when creating a new user, but this isn't officially documented. In general, we try to limit direct modifications of the registered users table, as there are some security concerns regarding how frequently the data is accessed and modified, but you can access the users object directly via the /users URL. There is an article in our documentation at http://docs.backand.com/en/latest/apidocs/security/index.html#link-your-app-39-s-users-with-backand-39-s-registered-users that covers an automated process for making these kinds of changes - you should be able to adapt some of the server side code in that example to work with your use case.
One alternative that would work now would be to have any change in basic information (username, password, firstname, lastname) result in a new user being created, and you could then use a custom action to perform the migration to the new user, but that is unnecessarily complex. I will add a ticket for our developers to look at adding this registered user management functionality in the future.

Using mod_scorm_insert_scorm_tracks

I'm interfacing my App with Moodle and I'm successfully calling mod_scorm_get_scorm_sco_tracks and mod_scorm_get_scorm_attempt_count via Ajax (XMLHttpRequest) for a given user (userid).
Now I want my App to push some SCORM tracks back to Moodle.
So I'm trying to use mod_scorm_insert_scorm_tracks but with no success.
The problem is that this method does not take an userid parameter, so I don't understand how to use it (and if I try to add userid to input params I get an invalid parameter exception).
I had kind of success (no error message) by sending this:
scoid=206&attempt=2&tracks[0][element]=cmi.completion_status&tracks[0][value]=completed&tracks[1][element]=cmi.interactions.0.id&tracks[1][value]=multiplechoice_page_1_1&tracks[2][element]=cmi.interactions.0.learner_response&tracks[2][value]=White&tracks[3][element]=cmi.interactions.0.result&tracks[3][value]=correct&tracks[4][element]=cmi.interactions.0.description&tracks[4][value]=Which%20color%20was%20Garibaldi's%20white%20horse%3F&tracks[5][element]=cmi.interactions.1.id&tracks[5][value]=hotobject_page_2_1&tracks[6][element]=cmi.interactions.1.learner_response&tracks[6][value]=butterfly&tracks[7][element]=cmi.interactions.1.result&tracks[7][value]=incorrect&tracks[8][element]=cmi.interactions.1.description&tracks[8][value]=Where%20is%20the%20fish%3F&tracks[9][element]=cmi.score.max&tracks[9][value]=2&tracks[10][element]=cmi.score.raw&tracks[10][value]=1&tracks[11][element]=cmi.score.scaled&tracks[11][value]=0.5&tracks[12][element]=cmi.session_time&tracks[12][value]=PT0H0M15S&tracks[13][element]=timemodified&tracks[13][value]=1480947821&tracks[14][element]=userid&tracks[14][value]=26&tracks[15][element]=scoid&tracks[15][value]=206&wstoken=69f2471506c4c49ff47cd0de0c4c9f01&wsfunction=mod_scorm_insert_scorm_tracks&moodlewsrestformat=json
However, since I cannot specify the user those data belongs to, my user's attempts does not update (as predictable).
This is the response from Moodle:
{"trackids":[44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59],"warnings":[]}
I've tried inserting the userid info into traks (tracks[14][element]=userid&tracks[14][value]=26) but still no luck.
So, the questions are:
Which user are those tracks inserted to considering that I'm calling it from an external app, so there's no logged in user in Moodle?
How can I specify that those tracks are for a give userid?
the user identity comes from the HTTP Context of a full login into Moodle: you can't provide SCORM tracking info on behalf of any user but the actual logged-in user.
More at:
https://github.com/moodle/moodle/blob/d33c67bc4744f901bf389607cfbbb683ef1c7d80/mod/scorm/classes/external.php#L451
https://github.com/moodle/moodle/blob/0b8e0c374f89ca20e5b9e7c9370761810811edc6/lib/externallib.php#L481
HTH,
Matteo

Automating posts from "company" for the Facebook page of said "company"

I put company in between quotations because my question relates to our Rugby team page but in Facebook it acts like a company page.
I am currently rebuilding my teams website (BBRFC Celtic) and I am going to add a user login system which will have coaches and admin staff with different levels of authority.
Sometimes due to weather conditions, events, or other things a training time may be changed or a match canceled or other various events. When these happen we normally send emails through a mailing list or sms or post on Facebook by hand.
What I want to have is a little bot of some kind that runs behind the scenes of the server and when coaches or admins change something it allows them to make an automated post to Facebook.
Something like after changing a trainings time it asking Would you like this to be posted to the facebook page and groups?.
I have been unsuccessful in finding out how I would go about writing the code for this. Our webpage will use php but maybe this can be done with javascript?
Do I need to get a key to post something as if I were the page?
How about to the different groups we have?
Any pointers would be helpful since I am totally stuck not really programmatically but more conceptually, I do not know if this is even possible.
I will explain the steps you need to accomplish your goal for a website. Note that the documentation also explains the case of a mobile application and others. I used the facebook API before, however, not to manage groups/pages, hence, this post will only point you in the right direction. I will explain how to post a message as being the admin of the page, not sure if you meant facebook pages or groups.
First, the user need to log in with facebook. This can be done using Javascript and the facebook API. Their documentation provides a very detailed explanation with code examples etc. Note that i will explain for the case of Javascript, however, this could be done in php, ...
Once the user is logged in, you can retrieve all kind of information about the user, his pages, etc. I would suggest to retrieve the pages the user is managing, then check if your "company" is part of this list (note that you will need the manage_pages permission). If this is the case, the user can post a message in name of the page.
/* Retrieve pages the user is managing */
FB.api(
"/me/accounts",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
Now response is an object containing multiple fields (see the official documentation).
Now, if the user is an administrator of your page, you can post a message as a Page.
/* Post a message as a Page, use your page id */
FB.api(
"/{page-id}/feed",
"POST",
{
"message": "The match has been delayed to ..."
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
If successful, the ID of the post will be returned as part of a JSON response (see doc)

ReactJS - how to setup login pattern?

I'm sorry if this question is a bit vague, but I'm tackling this problem for the first time and any pointer would be useful.
I am building a web app using ReactJS and I need a login system - first page with two fields username / password and submit button. The server returns a token (1234) and this needs to be used in an auth header (Authorization: Bearer 1234) in order to access the protected area.
How should I handle the login and make the browser update itself with the new content available after login?
As the others have pointed out, it is a good idea to use React-Router.
I think you can use pattern like this: You get user inputs and send them via AJAX (with JQuery, Superagent, whatever you want). If the input is valid and user authenticated, the server sends back token with some user info, which can include his roles or permissions. Based on these received data, you can use React-Router to render other component, e.g. welcome page (by calling replaceState on React-Router history object - in flux action for example).
Additionally, you should save this token in a cookie or into a session/local storage (in order to be able to use it on every subsequent request), and the user info could be stored in a Flux store. After saving this user the store emits change event, which should lead to rerender of your root component with the user information you got.
Then, based on the new user roles or permissions in your store, you can have for example ES7 decorator on some of your components deciding, if it displays the actual component or not.
Hope it helps you a bit.

Categories