Obtaining current logged in user with a script

You can obtain the currently logged in user in the following way.

Script without PublicAPI.

For correct functioning of the script you need the following namespaces:
using EleWise.ELMA.Security.Models;
using EleWise.ELMA.Security.Services;

Script text:

context.CurUser = (User)AuthenticationService.GetCurrentUser<EleWise.ELMA.Security.Models.IUser>();
where context.CurUser is the context variable of the User type that will store the value.
 
Creating a similar script with PublicAPI
Updated documentation on PublicAPI is available here.

Context variable:

Context.CurUser - User type variable
 
Namespace:
using EleWise.ELMA.API;

Script text:

context.CurUser = PublicAPI.Portal.Security.User.GetCurrentUser();
Starting from ELMA 3.8 there is a service for obtaining the current user
var curUser = PublicAPI.Services.Authentication.GetCurrentUser();