Commit 1e717d65 authored by owlo's avatar owlo

creating a user works

parent 3066cfa3
No preview for this file type
......@@ -8,6 +8,7 @@ type EndpointsS struct {
}
type ActorS struct {
Password string
Summary string
LastBork string
Source map[string]interface{}
......
......@@ -11,6 +11,7 @@ import (
"os"
"os/exec"
"strconv"
"strings"
"time"
"golang.org/x/crypto/openpgp"
......@@ -18,6 +19,8 @@ import (
"localtoast.net/localtoast/Ogopogo/libs"
)
var hostname string
func validateLogin(signature string, file []byte) bool {
if signature != "" {
......@@ -41,6 +44,8 @@ func validateLogin(signature string, file []byte) bool {
fmt.Println(florpScanner.Text())
if florpScanner.Text() == signature {
fmt.Println("LOGGED THE HECK IN")
florptext := strings.Split(florpScanner.Text(), ":")
createUser(florptext[0], florptext[1])
return true
}
}
......@@ -56,6 +61,33 @@ func validateLogin(signature string, file []byte) bool {
return false
}
func createUser(username string, password string) bool {
hostname = "http://snowcrash.network"
UID := UIDMaker("user")
userFile, err := os.Create("tests/" + UID)
if err != nil {
fmt.Println("Error creating userfile")
}
var userActor libs.ActorS
userActor.PreferredUsername = username
userActor.Password = password
for i := 0; i < 32; i++ {
fmt.Println("")
}
userActor.Inbox = hostname + "#inbox/" + username
userActor.Outbox = hostname + "#outbox/" + username
userActor.Following = hostname + "#following/" + username
userActor.Followers = hostname + "#followers/" + username
userData, err := json.Marshal(&userActor)
if err != nil {
fmt.Println("Error marshalling json.")
return false
}
userFile.Write(userData)
userFile.Sync()
return true
}
func validate(signature string, file []byte) bool {
bufferedReader, err := os.Create("tests/outfile")
......@@ -247,7 +279,7 @@ func initActors(currentActors string) string {
emptyString := ""
return emptyString
}
func UIDMaker() string {
func UIDMaker(typeS string) string {
hostname := "localhost"
username := "username"
//Inspired by 'Una (unascribed)'s bikeshed
......@@ -314,12 +346,24 @@ func UIDMaker() string {
uniqueFied := fmt.Sprint(uniquefier, hostname, username, adjectives[ind], adjectives[indie], nouns[thedog])
fmt.Println(uniqueFied)
numPosts, err := ioutil.ReadDir("tests/posts/")
if err != nil {
fmt.Println("Error, can't find post directory!")
if typeS == "post" {
numPosts, err := ioutil.ReadDir("tests/posts/")
if err != nil {
fmt.Println("Error, can't find post directory!")
}
UID := fmt.Sprint("posts/", len(numPosts)+1, uniqueFied)
return UID
}
if typeS == "user" {
numUsers, err := ioutil.ReadDir("tests/users/")
if err != nil {
fmt.Println("Error, can't find post directory!")
}
UID := fmt.Sprint("users/", len(numUsers)+1, uniqueFied)
return UID
}
UID := fmt.Sprint("/posts/", len(numPosts)+1, uniqueFied)
return UID
return "NOT NUMBERWANG"
}
func main() {
......@@ -364,7 +408,7 @@ func main() {
if req.Header.Get("Accept") == "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" {
fmt.Println("Accept header is correct.")
w.Header().Set("Content-Type", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
UID := UIDMaker()
UID := UIDMaker("post")
w.Header().Set("UID", UID)
w.WriteHeader(http.StatusOK)
fmt.Println("Signing test json.")
......@@ -465,7 +509,7 @@ func main() {
}
beachBall := object
fmt.Println(beachBall)
UID := UIDMaker()
UID := UIDMaker("post")
validate(UID, object)
})
......
This diff is collapsed.
No preview for this file type
This diff is collapsed.
This diff is collapsed.
{"Password":"bork","Summary":"","LastBork":"","Source":null,"Type":"","Following":"http://snowcrash.network#following/guarddoggo","Followers":"http://snowcrash.network#followers/guarddoggo","Liked":"","Inbox":"http://snowcrash.network#inbox/guarddoggo","Outbox":"http://snowcrash.network#outbox/guarddoggo","Url":"","Attachment":{"TypeS":"","Content":"","Url":""},"AttributedTo":{"TypeS":"","Name":""},"Audience":{"TypeS":"","Name":""},"Content":"","Id":"","Context":null,"Name":{"Context":"","TypeS":"","Name":""},"EndTime":{"Context":"","TypeS":"","Name":"","StartTime":"","EndTime":""},"Generator":{"TypeS":"","Name":""},"Icon":null,"InReplyTo":{"Summary":"","TypeS":"","Content":""},"Location":{"Name":"","TypeS":"","Place":""},"Preview":"","Published":"","Replies":{"TypeS":"","TotalItems":0,"Items":null},"StartTime":"","Tag":{"TypeS":"","Id":"","Name":""},"Updated":"","To":"","Bto":"","Cc":"","Bcc":"","MediaType":"","Duration":"","Position":{"Y":null,"X":null},"Streams":{"Location":"","Obj":{"Attachment":{"TypeS":"","Content":"","Url":""},"AttributedTo":{"TypeS":"","Name":""},"Audience":{"TypeS":"","Name":""},"Content":{"Content":"","Summary":"","TypeS":"","MediaType":""},"Context":{"Context":"","Summary":"","TypeS":"","Items":null},"Name":{"Context":"","TypeS":"","Name":""},"EndTime":{"Context":"","TypeS":"","Name":"","StartTime":"","EndTime":""},"Generator":{"TypeS":"","Name":""},"Icon":{"TypeS":"","Name":"","Url":"","Width":0,"Height":0},"InReplyTo":{"Summary":"","TypeS":"","Content":""},"Location":{"Name":"","TypeS":"","Place":""},"Preview":"","Published":"","Replies":{"TypeS":"","TotalItems":0,"Items":null},"StartTime":"","Summary":"","Tag":{"TypeS":"","Id":"","Name":""},"Updated":"","Url":"","To":"","Bto":"","Cc":"","Bcc":"","MediaType":"","Duration":"","Position":{"Y":null,"X":null}},"TotalItems":0,"Current":null,"First":"","Last":"","Items":null},"PreferredUsername":"guarddoggo","Endpoints":{}}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment