Sql and adding authentication to layout template