How do I make it possible that my spring boot application updates the created_by automatically when I have when say adding products to a product table - mysql

Dears, I am able to create a rest api that saves, deletes and updates products or asserts and within the asserts entity class I have a created_by field mapped to a database table which I can only update by typing my name every time to show that I am the one who have created it, but however this is not what I want, I have got a rest api that simply asks for my username and password and validate against the users table in the database.
So I want the this userid to continue to linger into the application session as long as the rest api app is running and then when I create new asserts(products) the methods defined for saving those products should automatically save that currently running user_id in memory.
I have no idea how I can accomplish this. Please any ideas.
I have created my entity classes for Asserts, Users and I can perform all CRUD actions on them successfully but the problem is on saving the user automatically without manually saving the user_id everytime an assert(product) is added, deleted, or updated.

Related

Using Auth0 ID to retrieve and update user info from MySQL

I created a ReactJS web app with a “user profile” page where the logged user can save: name, surname, email and address. For the moment, every time I log-in and save the data a new object is created.
I would like each logged user to be linked to a single ID, namely Auth0 one, so that I can always retrieve and update the row of the right user in my MySQL database.
I tried to look for other similar questions and to see the documentation, but it's my first time with authentication and I haven't found anything specific about Auth0,so I apologize if it’s a trivial question or asked several times .

Create a dynamic ICS file that users can subscribe to

We have a website that users login to, and can then book on to courses. These courses and the bookings are stored in our SQL database against the user's UserID. On the course page the user is able to add the course to their Outlook calendar via a simple ICS file that is generated when the user clicks on the button to add it by submitted the required data into the ICS file within the URL that calls it and then using <%=Request("CourseName")%> in the ICS file itself.
We are now looking to create a new ICS file that a user can subscribe to that will update their Outlook calendar with all of the courses they have signed up for, and will automatically update if/when a course has a change applied to it or if the user signs up to a new course then this will also automatically be added to their calendar. I can work out how to generate an ICS file that will hold all of this data using a similar setup to what I have done for the individual courses above, but I cannot work out how to create an ICS file that automatically updates with new information.
I don't know if I need to;
1. Have a hardcoded ICS file stored on the server for each individual user that is then updated as and when a change is made (I would prefer to avoid this as we have a lot of users)
2. If there is a way I can include a SQL statement within an ICS file that will then get the latest course data for the user on the fly (this is preferred, but testing this option so far has always resulted in errors)
3. Something else I have not thought of yet
Any help would be appreciated on this!
Here is the approach we are using to solve a similar problem:
Every time an admin changes an event or a user changes their subscription, we trigger an API call to do two things: (1) notify the relevant users of the changes using an auto-generated iCalendar event (.ics), and (2) update the database with the changes.
We opted to give the users and the administrators the power to trigger event-changes, rather than have a timer that checks and sends out updates, because we wanted to avoid the lag.
As to your question about auto-generating, this requires you to create an event_id, which you re-use in the .ics file, along with a METHOD:REQUEST, which notifies the user's email that you are sending a: (a) new event, or (b) change to a prior event. If you build a dynamic iCalendar script, this is possible. You must capture the "changes" and flow them through to a new .ics request.

Notification When user add item into database

i have a program that allow user to add data into database,but i want it look proper to admin to view the new item. Right now when user submit new data the admin can view all the data have been submitted from database but now i want the admin can alert the new data have been submitted by user. By the way i using asp.net,back end Vb.net and db is MYSQL.
There are huge variety of ways how you could implement desired feature. General algorithm is next
Commit each user data sumbission event into storage
Gather all events by timer
Render gathered facts in admin UI
To achieve this consider to use for step 1 MySQL triggers. Create additional table and save user data submission events into it.
Use scheduled asynchronous event monitoring for step 2,

Updating Woocommerce Orders Programmatically

I have an eCommerce site running Woocommerce on top of Wordpress, and the company running it has changed there shipping system to an external company who stores the products in their warehouse and ships the products when they are bought.
In terms of automation, downloading information on new orders and sending it to the shipping company is fine, but when they respond to me with an XML of the orders sent and the associated tracking numbers, I need to be able to have a system that automatically updates the orders (including sending out the emails necessary). However, the only way I currently know how to do that is to update the MySQL database. But with that method, the automated email system is overridden and ignored.
Does anyone know how I can update orders statues and other information programmatically, which would allow Woocommerce's internal functions to be executed in the same way as manually logging into the admin side and updating the order?
Found a solution to this yet?
The code below works to mark an order as complete, but does not execute other actions as you describe in the admin
// create a new checkout instance and order id
$checkout = new WC_Checkout();
$this_order_id = $checkout->create_order();
$order = new WC_Order($this_order_id);
$order->update_status('completed');

Maintain parallel, identical databases: MySQL and SharePoint FBA

I have 2 websites, and both have a login system, where the user can create an account to access a special portion of our website. Website A is a standard LAMP creation, and the user information is thus stored in a MySQL database. Website B is a site that is hosted on SharePoint and the user information is stored in a SharePoint Form Based Authentication (FBA) database.
I want to make it so that when a user creates an account on Website A, an account is automatically created on Website B.
Does anybody know of an easy way to do this? I'm thinking when the account is created on Website A, the website can send a query to both databases and create the same information. OR the 2 databases could be kept in sync somehow.
Any help would be greatly appreciated! Thanks much.
Regarding your first method: I think it's not good solution because you have to wait until server b won't response. Better way is to use event model based on queue.
You have queue of ids which are new created users and add user_id from the first server to this queue during user's creation. From other side you have cron script with infinite loop
while(1) {
sleep(10);
//check new user_id in queue
if (no) {
continue;
}
//create a new user in server B and remove user_id from queue
}