How to skip login in cakephp 2.6.7? - cakephp

I have an old cakephp application which requires login. I was working with the tables in phpmyadmin and I accidentally deleted the user login/password entry from the table. Now I am not able to login in the cakephp application. I tried to create a login entry in the table but I am not sure how to insert a password in it. it is not working with plain text password. I guess, app is looking for encrypted password which I don't know how to add to the table.
Either I need to disable the login from the cakephp application code and direct the user straight to the main page of the app
Or I need to encrypt the password correctly and insert it in the table.
Please help! I am not sure how to achieve either of these solutions.

Go to your Users Controller and add the actions you need to create and save a new user:
$this->Auth->allow('display','save');
so, you'll be able to anter to that controller actions without any login.

Related

Best way to implement one-time feature after signup?

Note: This is likely a duplicate question but I couldn't search for a solution/suggestion for my use case, so if anyone can re-direct me, that would be appreciated.
Problem: I have a NextJS application that runs on Prisma ORM and MySQL database. I am using NextAuth for OAuth authentication for sign up and log in.
So far the application works just fine but I want to check whether a user is logging in for the first time and redirect them to a set up page whether they would input personal details in order to populate a table on the database, so that the app can form a dynamic page based on their newly added information.
On the database, there are the user table (populated by NextAuth immediately at login) and the profile table.
Under NextAuth, the user table is populated automatically with the account's user name and email etc. However, that is not a unique entry and NextJS getStaticPath requires a unique entry to generate a dynamic page. That's why I have created the profile table to allow users to add their custom username where the dynamic URL will be generated (e.g. localhost:3000/u/[slug])
Here's my question - I want to check that the user is first time logging in and send a form for them to fill out the necessary information to input data onto the profile table, otherwise they would go straight to their profile homepage. What is the best way to check that and to redirect them to that form page?
Do I do it at server side with getServerSideProps by checking that the id from user table is missing from the profile table and do a redirect? Or is there some method that's customarily used to implement this "initial set-up" procedure?

What's the best way to save user data that's login from plugin(facebook or google)?

I have my own login form for my website. In addition I have also added google and facebook login.
My question is should I add those user data that's login from (fb or google) into my own userdata table or create a different one each for google and facebook.
1) If I add to my existing one, the password column would be left blank(as fb do not provide one) and anyone who knows the email will be able to access it easily.
2) And if I make different table then I think it will become little complicated or slower when trying to access a user data from across the different table.
What's the best choice of doing it or any other method that's better than this?
Make sure users have to enter a password when they login with Facebook/Google, or make sure regular users do not use a blank password - users without a password can only login with the Facebook/Google API.
DonĀ“t create a separate table, it will only get more complicated. Extend the existing one with IDs (from Facebook and Google).

How to use Wordpress function with new database

I am working on WordPress registration and login functionality. Actually I have 10 sites and I am making a single database table where these 10 sites can easily login and registered with same email and password. I mean same email and password can apply on these 10 sites login form through this single database table.
In my 10 sites there is one WordPress site. So I want the customize the registration and login functionality of this.
For my WordPress site I have make connect it with new database like:
$mydb = new wpdb('user','password','database','hostname');
after that I have check the database connection. it is working properly
Now I am getting a problem. I want to create a new user through this function
wp_create_user( $sanitized_user_login, $_POST['password'], $user_email );
when i am calling it through my new database connection like:
$mydb->wp_create_user( $sanitized_user_login, $_POST['password'], $user_email );
it is giving me blank result. So please tell me how can i get the all function of WordPress and use it for new database connection and create a new user in new database
Thanks
wp_create_user is a wordpress function
wdpb is used to work with db tables, there is no function wp_crete_user in wpdb. So you need to read the doc to know how to add a user in users table wpdb

Laravel database sessions

I'm building a Laravel website and I'm using the database driver to manage sessions. I created the sessions table in database and migrated with php artisan. Everything works as expected.
What I really want to do now is to check the role of the users that are online but I don't know how to get this with the fields of the sessions table in the database.
I don't really understand how the sessions table work, because I see that it registers a new row when I access to the login page, but it doesn't change when the user has logged in and when the user has logged out.
All I wanted is to check the role of the users active in the app....
Someone can help me with how to get to this?
Thank you!
I suggest you a very simple way. Just in your users table add a field called "is_online" that is 0 by default. When the user logs in , just change it to 1 and when he logs out change it back to 0. So DB::table('users')->where('is_online' , 1)->all() returns the online users.

CakePHP: Auth issue, suddenly can't login anymore, password query does not match database

While developing my app, I suddenly can't login using Auth anymore, according to Cake, the password or username is not correct.
When I track the query, the password (hashed) that Cake is looking for is not the one that the user has. I matched the query password to the User table in MAMP.
What can be the reason of this sudden error? What can Cake make looking for another password that not exists in the user table.
all error logs are clear
I can register a user without any issue
I use everything the standard Cake way (Auth, register process etc)
Many thanks!
well, most likely, you changed the salt value in core.php or hash mehod, or both. That's the only 2 reasons the hash is different for the same password.

Resources