Set user email with ETH address while authenticating #5
@ -4,8 +4,11 @@
|
|||||||
gqlPath = "/graphql"
|
gqlPath = "/graphql"
|
||||||
[server.session]
|
[server.session]
|
||||||
secret = ""
|
secret = ""
|
||||||
|
# Frontend webapp URL origin
|
||||||
appOriginUrl = "http://localhost:3000"
|
appOriginUrl = "http://localhost:3000"
|
||||||
|
# Set to true if server running behind proxy
|
||||||
trustProxy = false
|
trustProxy = false
|
||||||
|
# Backend URL hostname
|
||||||
domain = "localhost"
|
domain = "localhost"
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
|
@ -46,6 +46,9 @@ router.post('/authenticate', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// SIWE Auth
|
||||||
|
//
|
||||||
router.post('/validate', async (req, res) => {
|
router.post('/validate', async (req, res) => {
|
||||||
const { message, signature } = req.body;
|
const { message, signature } = req.body;
|
||||||
const { success, data } = await new SiweMessage(message).verify({
|
const { success, data } = await new SiweMessage(message).verify({
|
||||||
@ -61,11 +64,11 @@ router.post('/validate', async (req, res) => {
|
|||||||
if (!user) {
|
if (!user) {
|
||||||
const newUser = await service.createUser({
|
const newUser = await service.createUser({
|
||||||
ethAddress: data.address,
|
ethAddress: data.address,
|
||||||
email: '',
|
email: `${data.address}@example.com`,
|
||||||
name: '',
|
|
||||||
subOrgId: '',
|
subOrgId: '',
|
||||||
turnkeyWalletId: '',
|
turnkeyWalletId: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
// SIWESession from the web3modal library requires both address and chain ID
|
// SIWESession from the web3modal library requires both address and chain ID
|
||||||
req.session.address = newUser.id;
|
req.session.address = newUser.id;
|
||||||
req.session.chainId = data.chainId;
|
req.session.chainId = data.chainId;
|
||||||
|
@ -378,7 +378,7 @@ export class Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createUser(params: {
|
async createUser(params: {
|
||||||
name: string;
|
name?: string;
|
||||||
email: string;
|
email: string;
|
||||||
subOrgId: string;
|
subOrgId: string;
|
||||||
ethAddress: string;
|
ethAddress: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user