🧙♂
User Authentication
All Mu apps come with built-in with User Authentication.
All user authentication logic is located within in
mu.user
. When a user is logged in to mu.app their session will also be available from within your application.When a user first lands on your app their details will not be available to you. You will first need to call
mu.user.authenticate()
Once this is complete, the user will then be available to your app. This is to help you control the flow, as fetching the users details is asynchronous.
Here is an example:
<script>
async function main() {
await mu.user.authenticate()
// Once complete the user is available.
const user = mu.user.getUser()
// Run your app logic...
}
main()
</script>
Here is an example of a logged in user:
{
created: "1686737802",
email: "[email protected]",
id: "683d319b-59db-4129-84f2-4662cc48bd02",
profile: {
profilePicture: 'profile-picture.jpg'
},
updated: "1690380034"
username: "username"
verification_date: "1690380034"
verified: true
}
Last modified 1mo ago