How to do user authentication using a mysql databse - node.js

On a website:
After a successful login, how to stop sending the user to localhost/login cause he's already logged in, but send him instead to a localhost/index where there's a logout button.
Video reference (min 00:48)
https://youtu.be/DcB1Ge0HQ4I

That's a simple task ,,,did you create $_SESSION['loggedin'] = true;

Related

How to transfer data from page to another in node js

Hello there i am learning node.js and got stuck in a scenario.The flow is that in website user register himself and after successfully registering i will be sending him to route named create_profile which in is post request and also i want to send userId to create_profile route.In case if user close the website then if he agains open it and login then if profile is incomplete then i will be taking his userId and send to create_profile route.And after that to home page.What i was thinking to store session for user authentication in create profile page and login.This is because if login there can be tow cases : If user has successfully completed his profile then take him to home and store a global session there and second case it to take him to create profile as its incomplete then after successfully creating take him to home store global session for user authentication.But my confusion is to how to pass userId from login to create profile which is post request.Do i need to make temp session ? Please solve my issue i am confused how to solve this .
You can create a "profile_completed" coloumn in DB and set it as "false" (default), update it to "true" if user has completed the profile. While user login check if his profile is updated ,if yes send him to home else ask him to update.
You can pass user I'd to create_profile via request or get it from session storage you saved earlier

Xamarin Forms - Close view after successful login with Azure AD

I'm successfully logging in my Xamarin Forms application with Azure AD.
The problem is that when I'm logged in through the webview opened by default with :
user = await AuthenticationManager.DefaultManager.CurrentClient.LoginAsync(MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory, true);
The created webview shows a message telling me that I'm logged in but I don't know how to close this view after that.
Is there an event I can use or am I doing something wrong and the webview is supposed to close itself upon complete authentication ?
EDIT :
I changed my call to :
user = await AuthenticationManager.DefaultManager.CurrentClient.LoginAsync(MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory, false);
Becase I didn't give an SID being a Xamarin Forms project.
The result is that the window closes now but I get and InvalidOperationException with the message :
Invalid format of the authentication response.
Any idea about the format I should give ? I don't see what I could change to be able to get the user connected.
Just leave off the true/false on the end.
For more information on authentication, see chapter 2 of http://aka.ms/zumobook

Nextcloud external login for users in another database

I have a Nextcloud installation, with users stored in an external database, and this works fine with this app : https://apps.nextcloud.com/apps/user_sql
With that in place, I can login on my Nextcloud instance via the login form provided by Nextcloud.
I need to autolog the users when they come from another app.
I've written a PHP script, placed at the root of my Nextcloud installation, and it gets called by other internal apps of my company.
This script receives a userId and a token in the URL. After a successful check (no need to get in the details here), this script should log the user in.
Which API should I call to get the user logged in?
I tried the following, without success:
OC_User::login(...)
OC_User::getUserSession()->login(...)
Is there a way to trigger a valid login, so that I can get the users logged in?
Thank you for your answers, guys!
$user = '';
$pass = '';
$s = \OC::$server->getUserSession();
if (!$s->isLoggedin()) $s->login($user, $pass);
else $s->logout();
Placing this at /index.php and before calling OC::handleRequest() does the trick. It doesn`t work as expected but you could try to continue from here.
PD: Nextcloud Server v14.0.0 Alpha

NetSuite - Check if user is properly logged

I have a little question. I am working with NetSuite eCommerce and I need to check something, my site runs a script when user is logged, but sometimes it asks for a login even when still getting NetSuite Attributes. Something like this:
var loginEmail = "<%=getCurrentAttribute('customer','email')%>";
if(loginEmail==null || loginEmail=="") {
$("#cart").hide();
}
else {
$("#cart").show();
}
Do you know a specific NetSuite attribute or tag that I should be calling/using?
User sessions do time out after a period of inactivity, and user sessions are tracked with a cookie.
Try testing with a different browser - ie run NetSuite in FireFox and test the eCommerce functionality in Chrome or Safari, for instance.
Try nlapiGetLogin(). From NetSuite Help:
nlapiGetLogin
Returns the NetSuite login credentials of currently logged-in user.
This API is supported in user event, portlet, Suitelet, RESTlet, and SSP scripts. For information about the unit cost associated with this API, see API Governance.
Returns nlobjLogin
Since Version 2012.2
Example
This example shows how to get the credentials of the currently logged-in user.
//Get credentials of currently logged-in user
var login = nlapiGetLogin();
It doesn't say, but my thought is that this would return null if no user is logged in.
Use this code:
<%
var shoppingSession = nlapiGetWebContainer().getShoppingSession();
if (!shoppingSession.isLoggedIn())
$("#cart").hide();
else
$("#cart").show();
%>
In place of
<%=getCurrentAttribute('customer','email')%>
try using
<%=getCurrentAttribute('customer','entityid')%>

Node.js Meteor create a splash page with password to enter into the app. Keeping user login separate and inside the app past the splash page

Wanting to create a splash page where a user can enter a site password that is the same for everyone. It's to hide the site while it's in preview only. Not sure why I'm not getting how to do this. It's got to be relatively straight forward in meteor.
Currently have Meteor-Router installed. Is this the best approach? How do I go about this?
Thank you
Here is one possible answer in CoffeeScript:
Add a filter on the Router like:
Meteor.Router.filters
'authorizeUser': (page) ->
if Session.get 'knowsTheSecret' then page else 'splash'
Meteor.Router.filter 'authorizeUser'
That says every page request must have the knowsTheSecret session variable set or the user will get booted back to the splash page (defined elsewhere).
On the server (as in put this in the server directory). Create a method to validate the password:
Meteor.methods
checkSecret: (string) ->
string is 'super secret password'
When the user clicks the login button on your splash page, you can call the method like so:
Template.splash.events
'click button': ->
password = $('#text-field').val()
Meteor.call 'checkSecret', password, (err, result) ->
Session.set 'knowsTheSecret', result
So the Session varable will only get set if the user actually knows the secret. This, of course, is not secure in any real way (They user could just open a console and set the session variable manually) but it's a start. Play around with all that and see if it gets you closer to a working solution.

Resources