Auth for 2 different tables in cakephp 3.0 - cakephp-3.0

I want to use two tables for login one for admin and another user. Tables have different fields.
For that reason I don't want to use same table for authentication. How do I differentiate the authentication for login in cakephp 3.0

Related

User storage in ejabberd

I am trying to setup ejabberd as IM solution for my project, which will be mobile app + backend. I am using SQL auth (and SQL store for all modules also), using MSSQL via ODBC. I have some questions I didnt find answered in docs.
Do I understand correctly, that ejabberd is multi-tenant (since it can support multiple domains). If so, how are users assigned to particular tenant (domain)? In users table in DB, there is only username (without domain part). Can I have two different users john#jabber.myproject.com and john#jabber.myotherproject.net ?
I want to create XMPP accounts on ejabberd automatically (user doesnt need to know anything about underlaying service) - do I need to register users via API, or can I insert rows directly into DB table users and ejabberd will be OK with it?
In users table in DB, there is only username (without domain part). Can I have two different users john#jabber.myproject.com and john#jabber.myotherproject.net ?
Create a new database for each vhost, and use the host_config option in ejabberd.yml to tell which database to use for each vhost:
https://docs.ejabberd.im/admin/configuration/#database-and-ldap-configuration
Or you can enable the new SQL schema, see https://blog.process-one.net/ejabberd-18-03/
do I need to register users via API, or can I insert rows directly into DB table users and ejabberd will be OK with it?
Both are acceptable. In the second case, there are chances that some task performed at account registration is missing in your server, but I don't remember any module that performs any task at account registration. So, it looks OK.

How to architect an API first multi app platform?

I am trying to build an API first web app that has two parts:
Part A: The Project Management App. This would be built using php/mysql. One of the table in the mysql DB will be the users table where all users information will be stored viz username, password, email etc.
Part B: The online chat App. The users of the project management system will be able to chat among themselves. This will be built using nodejs/mongo. The mongodb DB would store the chat transcripts of each users and so would have a users collection containing the user details. The users collection would contain the same user information that the mysql users table has viz username, password, email etc.
Now, i have a couple of questions in terms of the architecture of this app.
Question 1: Is it at all a wise idea to maintain two different sources to store the user's information? The reason why I wanted to have a replica of the users table in the MongoDB as well is because since there will be too many reads and writes happening in the chat app so its best we use a nosql DB. (Lets assume here that my app will be used heavily going forward)
Question 2: If the answer to Question 1 is "Yes", how do we make sure of data consistency? I have thought of two approaches to achieve this:
Option A: Since we are using the API first approach, so during the registration of a user when the CREATE user api call is made, it will add the user in both mysql and mongodb databases.
Option B: I setup a cron that will sync the data between the mysql users table and the mongodb users collection periodically.
Can someone please throw some light on this and tell me if my approaches are right and that if I am going towards the right direction.
Many thanks

Can two laravel app use thesame database?

I have two laravel projects with setup as follows:
App1 - Web application portal
NB: Currently on a remote server
Allow students to submit applications and check the status of their applications online. Tables include (users, students, applications, documents, comments, faqs, answers)
App2 - Corp App
NB: On our local server
Allow to evaluate applications submitted via App1, view reports, manage selected applications, generate letters,
etc. Tables include (users, students, applications, documents, interns, attestations, supervisors, messages, etc). App2 do not share login information with App1. It mainly contains login info of corp employees while App1 only contain login info of students and site administrator. Tables common between the two dbs are students, applications, documents and via master-master replication we are able to get all applications submitted to App1 on the remote server and on App2 we can update the status of the applications which is sync back to App1 DB. Now we want both applications and db to be on thesame server and so for replication to work , that would mean installing two instances of mysql with each database on a separate instance. Would it be better to just include all the tables of the website - App1 (comments, faqs, answers, etc) on App2 DB and make both applications now use one database?
I think it would be the easiest solution with one database.
here is a link on how to use laravel and lumen together:
http://blog.enge.me/post/building-api-your-laravel-application-lumen
not excactly the same, but i think the principles can be reused for your project.
BTW, doesn't laravel 5.2 support user roles out-of-the-box?
When i think about it, you can actually do it with 2 user tables and 2 user models, each with its own login controller/middleware. Then you point the students to domain.com/student/login and the employees to domain.com/employee/login.

Auth for 2 different tables - Cakephp 3.X

I have table users (for admin) & players (front-end users). I have successfully implemented Auth for admin.
Now I want to implement same for players. I cannot merge users and players table since both have different foreign keys and many tables are dependent on them.
Also, Player registration is done from a different form with many more fields then Admin.
Can anybody please help me?
I started using CakePHP 3.X

Offering WP-Members and Facebook login options together seamlessly

I am starting a website and activated WP-Members for my user registration/login. This is great because I can then easily capture user_id in the MySQL table for writing my queries. But I am thinking I probably should also offer Facebook login or maybe even the Social Connect plugin as well.
The problem I'm guessing is that facebook login or any such social media login will use a different variable for user_id (such as fb_login) and so users who login this way will not be placed in the same Members table as users who login with WP-Members. Therefore, I'm not sure the easiest way to go about offering both registration methods.
Is it just too complex to do in general for a newbie to make both registration options establish users in the same table or at least make it easy for me to reference user_id for both methods when trying to run user-id conditional statements and such?
The problem I'm guessing is that facebook login or any such social
media login will use a different variable for user_id (such as
fb_login) and so users who login this way will not be placed in the
same Members table as users who login with WP-Members.
Unless a membership plugin creates and uses its own user table, all users are saved in the same table in WordPress - wp_users. Altering that would severely restrict your ability to integrate with other plugins and/or WordPress itself since you'd be trying to manage two separate user tables.
That isn't really the problem you're facing, but I wanted to mention it because in order to address your issue, your mindset has to understand the db schema you are working with.
WP-Members uses the WP db schema so that it will maintain compatibility not only with WordPress, but also with other plugins. There is not need to separate login/registration using a separate table (in fact, I'd advise against that). There are WP-Members users who use Social Connect just fine. They can be integrated because they rely on the same database.