I have been successful in getting the portal user in a widget developed using WAB developer version v1.0 . Below is code snippet to get the portal user.
"this.portal = portalUtils.getPortal(this.appConfig.portalUrl);
var username = this.portal.user.username;"
I am able to get the the current portal username when I debug the widget. I am even able to get the portal username when I launch it through web app builder app url.
The issue is when download the code and deploy it in IIS. The application throws the error and the username is undefined . On further debugging what I could find is the application is not able get the portal username.