Get current user email

Hi,

can someone give me a hint on how to get the Email of the current user?

For example, using embedded Form you can get the current user Name by this:

$scope.userName = $rootScope.authentication.name;

Hi @kok,
Try below snip of code.

<script cam-script type="text/form-script">
inject([ '$rootScope', '$scope', 'camAPI', function($rootScope, $scope, camAPI) {

	var userName = $rootScope.authentication.name;
	var User = camAPI.resource('user');

	User.profile({id: userName}, function(err, data) {
		if (!err) {
			//alert('Data: ' + JSON.stringify(data));
			alert('Email: ' + data.email);
		}
	});
}]);
</script>
1 Like

Hi @hassang,

thank you for your response. The truth is, I don’t know how to use this code. I tried to google it but it didn’t work.

I was thinking about fetching the current user email, like in this example: https://forum.camunda.org/t/logged-in-user-id-for-task-form-javascript/789/14

hopefully i could explain my problem.