I am new to grails and in my web application I want to create a random token with a length of 15 characters along with the username. And tokens must be unique.
All characters from az and 0-9 can be used, but do not have special characters. I tried to create an arbitrary token using
def generator = {String alphabet, int n -> new Random().with { (1..n).collec alphabet[ nextInt( alphabet.length() ) ] }.join() }} generator( (('A'..'Z')+('0'..'9')).join(), 9 )
but how can I add the username infront to the token like "JayKay586464ASDHH445"
Jaykay
source share