Skip to content

Commit

Permalink
Merge pull request #1158 from dm3-org/update-profile-backend-fix
Browse files Browse the repository at this point in the history
update profile backend changes
  • Loading branch information
AlexNi245 authored Aug 29, 2024
2 parents 730297e + a121a39 commit 247c9ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
5 changes: 2 additions & 3 deletions packages/offchain-resolver/src/http/profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe('Profile', () => {
expect(body.error).to.equal('invalid profile');
});

it('Rejects if subdomain has already a profile', async () => {
it('Updates profile if subdomain has already a profile', async () => {
app.use(profile(provider));

const offChainProfile1 = await getSignedUserProfile();
Expand Down Expand Up @@ -291,8 +291,7 @@ describe('Profile', () => {
subdomain: 'beta-addr.dm3.eth',
});

expect(res2.status).to.equal(400);
expect(res2.body.error).to.eql('subdomain already claimed');
expect(res2.status).to.equal(200);
});
it('Rejects if subdomain is not supported', async () => {
app.use(profile(provider));
Expand Down
19 changes: 0 additions & 19 deletions packages/offchain-resolver/src/http/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,6 @@ export function profile(web3Provider: ethers.providers.BaseProvider) {
return res.status(400).send({ error: 'invalid profile' });
}

const hasAddressProfile =
!!(await req.app.locals.db.getProfileContainer(address));

//One address can only claim one subdomain
if (hasAddressProfile) {
return res.status(400).send({
error: 'address has already claimed a subdomain',
});
}

const name = `${address}.${subdomain}`;

//ask the subdomain manager if the names subdomain is supported
Expand All @@ -286,15 +276,6 @@ export function profile(web3Provider: ethers.providers.BaseProvider) {
});
}

const profileExists =
!!(await req.app.locals.db.getProfileContainer(name));

if (profileExists) {
return res
.status(400)
.send({ error: 'subdomain already claimed' });
}

await req.app.locals.db.setUserProfile(
name,
signedUserProfile,
Expand Down

0 comments on commit 247c9ce

Please sign in to comment.