// Return an account that matches, or issue an error
Return an account that matches, or issue an error
// Return an account that matches or issue an error
func ValidateRequest(response http.ResponseWriter, request *http.Request) (*accounts.Account, error) {
	tokenString := request.Header.Get("Authorization")
	if tokenString == "" {
		buffer := []byte("Missing Token, Authenication Failed")
		response.Write(buffer)
		return nil, errors.New("Missing Token, Authentication Failed")
	}
	token := accounts.NewToken(tokenString)
	if !accounts.Validate(token) {
		buffer := []byte("Invalid Token, Authenication Failed")
		response.Write(buffer)
		return nil, errors.New("Invalid Token, Authentication Failed")
	}
	username := request.Header["Name"][0]
	if username == "" {
		fmt.Println("Missing Account", username)
		return nil, errors.New("User not Registered")
	}
	account := Global().Auth.Find(username)
	if account == nil {
		fmt.Println("Missing Account Information ", username)
		return nil, errors.New("User not Registered")
	}
	return account, nil
}
func ValidateRequest ( response http . ResponseWriter , request * http . Request ) ( * accounts . Account , error ) { tokenString := request . Header . Get ( " " ) if tokenString == " " { buffer := [ ] byte ( " " ) response . Write ( buffer ) return nil , errors . New ( " " ) } token := accounts . NewToken ( tokenString ) if ! accounts . Validate ( token ) { buffer := [ ] byte ( " " ) response . Write ( buffer ) return nil , errors . New ( " " ) } username := request . Header [ " " ] [ 0 ] if username == " " { fmt . Println ( " " , username ) return nil , errors . New ( " " ) } account := Global ( ) . Auth . Find ( username ) if account == nil { fmt . Println ( " " , username ) return nil , errors . New ( " " ) } return account , nil }
Return an account that matches, or issue an error
Return an account that matches or issue an error