Authenticate MetaMask iOS browser: Error: Not Allowed

Iā€™m using the code from the YouTube tutorial: https://github.com/MoralisWeb3/youtube-tutorials/tree/main/react-metamask-login

Iā€™ve updated Moralis dependencies to the latest:

ā€œdependenciesā€: {
ā€¦
ā€œmagic-sdkā€: ā€œ7.0.0ā€,
ā€œmoralisā€: ā€œ^1.3.2ā€,
ā€œreact-moralisā€: ā€œ^1.3.1ā€
},

Desktop works fine, as well as Coinbase Wallet mobile browser

When using MetaMask mobile browser I get ā€œError: Not Allowedā€

you mean that you opened your app in the internal browser provided by metamask?

where from is that error?

Yes, internal MetaMask browser.

The error comes from:

const { ā€¦, authError} = useMoralis()

can you try it outside of the metamask browser ? like on chrome or safari ?

Also, I get this error in Moralis Logs

Screenshot 2022-02-21 at 10.31.58

it works outside MetaMask browser

@0xprof @cryptokid

Hereā€™s also another log

I think Iā€™m nailing down where the error comes from.

I have this Cloud Function to prevent users changing some user fields:

Moralis.Cloud.beforeSave(Moralis.User, (request) => {
const userObject = request.object;
if (!request.master && userObject.dirty(ā€œcouponā€) || !request.master && userObject.dirty(ā€œraffleā€)) {
throw ā€œNot allowed.ā€;
}
});

The question now is, how to adjust it to allow new user creations?

it looks like you have to update this logic

well, I donā€™t see anything wrong with these statements :sweat_smile:

weirdā€¦

How do I check if a field coming from userObject has the default value on creation?

Ok, I found a fix:

Moralis.Cloud.beforeSave(Moralis.User, (request) => {
    const userObject = request.object;
    if (userObject.id && !request.master && userObject.dirty("coupon") || userObject.id && !request.master && userObject.dirty("raffle")) {
        throw "Not allowed.";
    }
});

If thereā€™s a better way to check, please let me know :slight_smile: