Bugfixes and freedback addressing

This commit is contained in:
2017-10-08 18:42:48 +02:00
parent f471aed610
commit e31d994d4b
7 changed files with 12 additions and 13 deletions
+4 -2
View File
@@ -28,8 +28,9 @@ func (wikiAuth *WikiAthenticator) Name() string {
// Find finds a user that has logged in at least once // Find finds a user that has logged in at least once
func (wikiAuth *WikiAthenticator) Find(username string) *auth.User { func (wikiAuth *WikiAthenticator) Find(username string) *auth.User {
db := server.Main.DB db := server.Main.DB
fullID := wikiAuth.ID() + ":" + username
rows, err := db.Query("SELECT id,role FROM `user` WHERE id=?", username) rows, err := db.Query("SELECT id,role FROM `user` WHERE id=?", fullID)
if err != nil { if err != nil {
log.Println("WikiAthenticator.Find:", err) log.Println("WikiAthenticator.Find:", err)
return nil return nil
@@ -45,6 +46,7 @@ func (wikiAuth *WikiAthenticator) Find(username string) *auth.User {
role := "member" role := "member"
rows.Scan(&user.ID, &role) rows.Scan(&user.ID, &role)
user.Data["role"] = role user.Data["role"] = role
user.ID = strings.SplitN(user.ID, ":", 2)[1]
return user return user
} }
@@ -79,7 +81,7 @@ func (wikiAuth *WikiAthenticator) Login(username, password string) (*auth.User,
return nil, fmt.Errorf("Login failed %v", err) return nil, fmt.Errorf("Login failed %v", err)
} }
return auth.NewUser(wikiAuth, fullID, "member", nil), nil return auth.NewUser(wikiAuth, username, "member", nil), nil
} }
// If the user was found, read it in // If the user was found, read it in
-3
View File
@@ -3,7 +3,6 @@ package formparser
import ( import (
"errors" "errors"
"fmt" "fmt"
"log"
"time" "time"
) )
@@ -31,8 +30,6 @@ func Select(value string, target *string, allowedValues []string, optional bool)
return nil return nil
} }
log.Println(value, allowedValues)
for _, allowedValue := range allowedValues { for _, allowedValue := range allowedValues {
if value == allowedValue { if value == allowedValue {
*target = value *target = value
+4 -4
View File
@@ -21,11 +21,11 @@ func (category *PageCategory) URLRoot() string {
// a limited selection of categories. I may move it to a configuration // a limited selection of categories. I may move it to a configuration
// or the database, but for now I think this list is pretty fixed // or the database, but for now I think this list is pretty fixed
var PageCategories = []PageCategory{ var PageCategories = []PageCategory{
{"OoC", "OoC", "O", "OoC content is for announcements, scheduling, general information, or anything that is not in-universe"}, //{"OoC", "OoC", "O", "OoC content is for announcements, scheduling, general information, or anything that is not in-universe"},
{"Info", "Info", "i", "Information gained during and between RP sessions"}, {"Info", "Info", "i", "Information relevant to RP that might be something looked for in IRC logs"},
{"News", "News", "N", "News stories that might be pertinent to ongoing plots"}, {"News", "News", "N", "News stories that might be pertinent to ongoing plots"},
{"Item", "Items", "I", "Items relevant to plots, that is more than just a document saved on a character's own omni-tool"}, //{"Item", "Items", "I", "Items relevant to plots, that is more than just a document saved on a character's own omni-tool"},
{"Document", "Document", "D", "Data files, shadow broker dossiers, and other data that is not inside an item"}, {"Document", "Documents", "D", "Data files, shadow broker dossiers, and other data that is not inside an item"},
{"Background", "Background", "B", "Rumors, suspicious persons, or inter-RP occurences that may be noticed"}, {"Background", "Background", "B", "Rumors, suspicious persons, or inter-RP occurences that may be noticed"},
{"Story", "Stories", "S", "Background stories and inter-RP character intearactions"}, {"Story", "Stories", "S", "Background stories and inter-RP character intearactions"},
} }
+2
View File
@@ -206,6 +206,8 @@ func parseHeader(header *Header, rows *sql.Rows) error {
rows.Scan(&header.ID, &header.Name, &header.Author, &header.Category, &fictionalDate, &publishDate, &editDate, &header.Dated, &tagID, &tagType, &tagName) rows.Scan(&header.ID, &header.Name, &header.Author, &header.Category, &fictionalDate, &publishDate, &editDate, &header.Dated, &tagID, &tagType, &tagName)
if tagID != "" { if tagID != "" {
header.PrimaryTag = &Tag{tagID, tagType, tagName} header.PrimaryTag = &Tag{tagID, tagType, tagName}
} else {
header.PrimaryTag = nil
} }
header.FictionalDate, err = time.Parse("2006-01-02 15:04:05", fictionalDate) header.FictionalDate, err = time.Parse("2006-01-02 15:04:05", fictionalDate)
+1
View File
@@ -16,6 +16,7 @@ var TagTypes = []string{
"Event", "Event",
"Organization", "Organization",
"Source", "Source",
"Series",
} }
// Tag describes a tag // Tag describes a tag
+1 -1
View File
@@ -7,7 +7,7 @@ CREATE TABLE user (
INDEX(role) INDEX(role)
); );
INSERT INTO user (id, role) VALUES("test:Test", "restricted") INSERT INTO user (id, role) VALUES("test:Test", "restricted");
CREATE TABLE page ( CREATE TABLE page (
`id` CHAR(16) NOT NULL PRIMARY KEY, `id` CHAR(16) NOT NULL PRIMARY KEY,
-3
View File
@@ -2,7 +2,6 @@ package viewmodel
import ( import (
"fmt" "fmt"
"log"
"git.aiterp.net/AiteRP/aitestory/server" "git.aiterp.net/AiteRP/aitestory/server"
"git.aiterp.net/gisle/wrouter/auth" "git.aiterp.net/gisle/wrouter/auth"
@@ -23,8 +22,6 @@ type Base struct {
// InitBase initializes the base of the viewmodel // InitBase initializes the base of the viewmodel
func (base *Base) setupBase(user *auth.User, viewTitle string) { func (base *Base) setupBase(user *auth.User, viewTitle string) {
if user != nil { if user != nil {
log.Printf("%+v", user)
base.User.ID = user.FullID() base.User.ID = user.FullID()
base.User.Name = user.ID base.User.Name = user.ID
base.User.Role = user.Data["role"] base.User.Role = user.Data["role"]