NextAuth v4 Beta - DB Session - Storing extra fields from OAuth Login Response - mongodb

I was trying to implement the OneLogin authentication using the NextAuth for my NextJS app. I was able to get everything done and is connected to MongoDB. But trying to figure out how to store extra data received from OneLogin
Since I enabled the debug option in the NextAuth, I was able to see the following in logs in the OAUTH_CALLBACK_RESPONSE from OneLogin, and would like to include these three fields to the database's users collection against the user:
OAuthProfile: {
given_name: "",
family_name: "",
preferred_username: "",
......
}
Because I want to set the name field of the User (that will be stored in database), with the value from given_name from the OAuthProfile (example above).
And also I would like to add an extra field like auth_level with a default value of "user", to denote that this User is by default a normal User. No elevated privileges' or anything.

Related

Heroku-Connect with Postgres and Salesforce : The new rows are not synchronized

I'm trying to use Heroku Connect to integrate a Postgres database with Salesforce.
The goal is to add more data from DB to Salesforce.
After connecting I can see updates from Salesforce in Postgres.
I can update existing posts in Postgres and see them in Salesforce.
I can create new records in tables like Leeds, Accounts and Contacts and see all the updates in Salesforce.
The problem with the Opportunity table I manage to update existing records from Postgres, but can not create new records to synchronize with Salesforce.
I.e. produces but updates does not go to Salesforce.
The error obtained is:
{"op": "INSERT", "src": "SFDC", "msg": "We can't save this record because the \u201cOpportunity - Owner Assignment\u201d process failed. Give your Salesforce admin these details. This error occurred when the flow tried to update records: INVALID_CROSS_REFERENCE_KEY: Owner ID: owner cannot be blank. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1878853328-1317082 (142283924)k up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1878853328-1317082 (142283924)"}
I.e. error tells me that ownerid is blank. But this field is not empty because I give the correct values of ownerid.
INSERT INTO salesforce.opportunity ( name , closedate, stagename, createdbyid, ownerid )
Values('zzzz' ,'2021-12-31','New', '0051t000002VZvKAAW','0051t000002VZvKAAW' )
In Heroku connect this like that:
What could be a problem ??
From the error reported it appears you have a flow configured on the opportunity object. Check the flow logic to see what downstream updates are occurring that could produce this error, or disable the flow temporarily to verify your insert works as expected.

How to retrieve multiple users at once with the GitHub API?

I'm able to get a single user, or all users created since a timestamp, or where there is some search match with the GitHub API.
https://developer.github.com/v3/users/#get-a-single-user
https://developer.github.com/v3/users/#get-all-users
https://developer.github.com/v3/search/#search-users
What I haven't been able to figure out is if there is a way to send something like a list of logins and get back all of those users at once.
My use case is that I'm pulling back a list of members off of an org. This provides me with enough data that I could loop through each individual user and get the detailed user data that I need this way, but I would rather not be hammering GitHub's API with a bunch of extra requests if it is not necessary.
Using GraphQL API v4, you could build a dynamic query with as many user you have in your array & use aliases for each one :
query {
user1: user(login: "aisalmi") {
...UserFragment
}
user2: user(login: "bertrandmartel") {
...UserFragment
}
user3: user(login: "molokoloco") {
...UserFragment
}
}
fragment UserFragment on User {
login
name
}
I also use a fragment to avoid field duplication
Test it in the explorer

how to give backend login acces to groups/roles other than administrator in fuelphp?

I am using Ormauth as auth package and used it for login at backend. Now I want to give login access for group 'moderator' along with 'superadmmin' and 'administrator'. How I am to proceed ? I tried changing options in default fuelphp tables for 'user_roles', 'user_role_permissions' and so on but to no avail. I am new to this ? Any help/suggestions are welcome. Thanks in advance.
i do this:
create a base class for admin area, in function "before" of that base class use \Auth::has_access('area.permission') for check that current user has access to current controller or not,
create some permissions (in table users_permission) for your admin area, you can use any names for area and permissions here but i suggest use your application or module name as "area" and controller name as "permission",
if you wish to use "groups" so use "users_grouppermission" or if you wish to use "roles" then use "users_rolepermission" for inserting some recordes for allowing access to groups/roles,
at least assign users to that groups or roles (using user_roles and user_groups tables)

Setting up user form in a Web Client for a REST API

I having trouble trying to figure out a standard "best-practice" to handle forms for a web application that interacts with a REST-like service.
For Example:
There is a registration/updating form for users, the UI require the user to specify the following fields
Name: Input field
Age: Input field
Country: Select Field
This functionality relies on two uris patterns
/user/{user_id} : In order to GET, POST, DELETE and PUT information about users
/country/ : This helps filling up the available options for the "Country" select field of the form it comprises a "Contry Id" (option value) and a "Country Name" (option text)
When a new user enters the registration forms the "Country" select input options are populated with the info of /country, then the user fills the form the data that is being POST to /user/
When a user is being edited the form has to be initialized with the user info, this requires two requests (one for the select list and another for the user data).
In this case, initializing the form is pretty easy but complex when considering populating too many "list"-like form controls.
What would be the best way to handle "form setup" (list options, radios, combos, checkboxes) and "resource data load" (the entity data)?
thanks

Password Protect a form in MS Access 2003

I am trying to create a login for my database and I don't want to use the Microsoft way of doing so. I want to have the users login with a username and password then have that information verified in the "tblUsers" table.
UserID LoginID Level LevelID
jpurk jack23 admin 3
krimes kitty editor 2
lwalms low34 reader 1
I got as far as verifying the "UserID" and "LoginID" using dlookup
Nz(DLookup("[LoginID]", "tblUsers", "[UserID] = '" & Me.txtUserID & "'"), "")
=Me.txtPassword
The problem I have now is that I want certain items on the menu unavailable to users without the proper Level; If they are only an "editor" or a "reader", then I don't want them to have access to the "administrative" button where I have placed all admin forms.
After I use dLookup to verify the username and password, how do I now find out their "Level" and assign rights to different menu items? Thank you.
Assuming your DLookup has found an existing LoginID value, you can use another to retrieve that user's LevelID. Then enable/disable the administrative command button based on their LevelID.
I'll suggest something like this in Form Load:
Dim lngLevelID As Long
lngLevelID = DLookup("[LevelID]", "tblUsers", "[LoginID] = " & Me.txtLoginID)
Me.cmdAdmin.Enabled = (lngLevelID = 3)
Notes: That assumes you've previously loaded the user's LoginID number into a text box named txtLoginID. txtLoginID could be hidden if you don't want the users to see it. Or you can grab the LoginID value by some other method.
If you have one-to-one matches between Level and LevelID, you shouldn't need to store both values in tblUsers. You can create a UserLevels lookup table to hold both, and store just the LevelID in tblUsers as a foreign key to the appropriate row in UserLevels.
Finally, the strategy you're using can work, but the security is shaky. As "guidance" to users willing to follow the rules, it's OK. But it can be easily circumvented by even unsophisticated users. Look for a different approach if your security needs are stringent.