<commit_before>package controllers

import (
	"github.com/astaxie/beego"
)

type Registration struct {
	Username string
	Password string
}

type RegistrationsController struct {
	BaseController
}

func (this *RegistrationsController) Prepare() {
	this.PrepareXsrf()
	this.PrepareLayout()
	this.Layout = "layouts/default.html.tpl"
}

func (this *RegistrationsController) New() {
	this.TplNames = "registrations/new.html.tpl"
}

func (this *RegistrationsController) Create() {
	registration := Registration{}
	err := this.ParseForm(&registration)
	if err == nil && registration.Username != "foo" && registration.Username != "admin" {
		this.SetSession("username", registration.Username)
		this.RequireAuth()
		this.Redirect(beego.UrlFor("HomeController.Get"), 302)
	} else {
		this.Redirect(beego.UrlFor("RegistrationsController.New"), 302)
	}
}<commit_msg>Add backend to register form.<commit_after>package controllers

import (
	"github.com/astaxie/beego"
	"ustackweb/models"
)

type Registration struct {
	Username string
	Password string
}

type RegistrationsController struct {
	BaseController
}

func (this *RegistrationsController) Prepare() {
	this.PrepareXsrf()
	this.PrepareLayout()
	this.Layout = "layouts/default.html.tpl"
}

func (this *RegistrationsController) New() {
	this.TplNames = "registrations/new.html.tpl"
}

func (this *RegistrationsController) Create() {
	registration := Registration{}
	err := this.ParseForm(&registration)
	if err == nil {
		models.Users().Create(registration.Username, registration.Password)
		this.Redirect(beego.UrlFor("SessionsController.New"), 302)
	} else {
		this.Redirect(beego.UrlFor("RegistrationsController.New"), 302)
	}
}
{'fraction_non_alphanumeric': 0.13066825775656324, 'fraction_numerical': 0.007159904534606206, 'mean_word_length': 5.628458498023716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7238282', 'n_tokens_mistral': 567, 'n_tokens_neox': 539, 'n_words': 104}