added lastLogin to publishers
This commit is contained in:
@ -145,11 +145,17 @@ export const authOptions: NextAuthOptions = {
|
||||
user.id = dbUser.id;
|
||||
//user.permissions = dbUser.permissions;
|
||||
const session = { ...user };
|
||||
|
||||
prisma.publisher.update({
|
||||
where: { id: dbUser.id },
|
||||
data: { lastLogin: new Date() }
|
||||
});
|
||||
return true; // Sign-in successful
|
||||
} else {
|
||||
// Optionally create a new user in your DB
|
||||
// Or return false to deny access
|
||||
return false;
|
||||
//Let's customize the error message to give a better user experience
|
||||
throw new Error(`Твоят имейл '${user.email}' не е регистриран в системата. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
@ -39,6 +39,7 @@ function ContactsPage({ publishers, allPublishers }) {
|
||||
<th className="border-b font-medium p-4 pl-8 pt-0 pb-3">Име</th>
|
||||
<th className="border-b font-medium p-4 pt-0 pb-3">Възможности</th>
|
||||
<th className="border-b font-medium p-4 pt-0 pb-3">Участия</th>
|
||||
<th className="border-b font-medium p-4 pt-0 pb-3">Последно влизане</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -67,6 +68,7 @@ function ContactsPage({ publishers, allPublishers }) {
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td className="border-b p-4">{pub.lastLogin ? common.getDateFormated(pub.lastLogin) : ""}</td>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
@ -125,7 +127,7 @@ export const getServerSideProps = async (context) => {
|
||||
const prisma = common.getPrismaClient();
|
||||
const dateStr = new Date().toISOString().split('T')[0];
|
||||
|
||||
let publishers = await data.filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth', dateStr, false, true, true);
|
||||
let publishers = await data.filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin', dateStr, false, true, true);
|
||||
|
||||
// const axios = await axiosServer(context);
|
||||
// const { data: publishers } = await axios.get(`api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
|
||||
@ -175,6 +177,7 @@ export const getServerSideProps = async (context) => {
|
||||
phone: true,
|
||||
isActive: true,
|
||||
desiredShiftsPerMonth: true,
|
||||
lastLogin: true,
|
||||
assignments: {
|
||||
select: {
|
||||
id: true,
|
||||
|
Reference in New Issue
Block a user