Source for SMSqueakMapView>>autologin

autologin
	"Handle a first login to a new account."

	| username account b msg pwd newPassword verifyPassword label password uname |
	b := self builder.
	b h1: 'Welcome to SqueakMap!'.
	b p: 'Since email is not a safe transport you can now type in a personal password.'.
	b postForm; columns: 2.
	b html: 'Developer initials: '; colTab.
	label := b var.
	b colTab.
	username := b inputHidden: #username.
	password := b inputHidden: #password.
	b isPost
		ifTrue: [
			uname := username value.
			pwd := password value]
		ifFalse: [
			uname := b at: #u ifAbsent:[^self message: 'No account with those initials!'].
			pwd := b at: #p ifAbsent:[^self message: 'Wrong password!'].
			username value: uname.
			password value: pwd].
	account := model accountForUsername: uname.
	account ifNil: [^self message: 'No account with those initials!'].
	label value: '<b>', account initials, '</b>'.
	(account correctPassword: pwd) ifFalse:[^self message: 'Wrong password!'].
	newPassword := b html: 'New password: '; colTab; inputPasswordSize: 15.
	verifyPassword := b colTab; html: 'Confirm password: '; colTab; inputPasswordSize: 15.
	b endColumns; br; submit: 'Save and continue'.
	b h2: [ msg := b var ].
	b endForm; end.
	b ifPost: [
		(newPassword value = verifyPassword value)
			ifFalse:[msg value: 'Confirm failed, enter passwords again']
			ifTrue: [
				account setPassword: newPassword value.
				account newPassword: nil.
				KomSession current attributes at: #account put: account.
				^self redirectTo: #account]
	].
	^b