<commit_before>package database

import(
	//"database/sql"
	//_ "github.com/bmizerany/pq"
	"log"
)

const qIsSessionValid = "select count(*) from gf_users where session=$1"

func IsSessionValid(token string)bool{
	conn := Open()
	defer conn.Close()

	var count int64

	row := conn.QueryRow(qIsSessionValid, token)
	
	err := row.Scan(&count)

	if err != nil{
		log.Println(err)
		return false
	}

	return count == 1

}<commit_msg>added check function for username and password<commit_after>package database

import(
	//"database/sql"
	//_ "github.com/bmizerany/pq"
	"log"
)

const qIsSessionValid = "select count(*) from gf_users where session=$1"

func IsSessionValid(token string)bool{
	conn := Open()
	defer conn.Close()

	var count int64

	row := conn.QueryRow(qIsSessionValid, token)
	
	err := row.Scan(&count)

	if err != nil{
		log.Println(err)
		return false
	}

	return count == 1

}

const qIsUserPasswordValid = "select session from gf_users where login=$1 and pw=$2 "

//Checks if user and password combination are valid
//returns "" if not, else the session token for the user
func IsUserPasswordValid(username, password string)string{
	conn := Open()
	defer conn.Close()

	var session string
	
	row := conn.QueryRow(qIsUserPasswordValid, username, password)

	err := row.Scan(&session)

	if err != nil{
		return nil
	}

	return session
}
{'fraction_non_alphanumeric': 0.11925925925925926, 'fraction_numerical': 0.007407407407407408, 'mean_word_length': 4.176245210727969, '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': '3990022', 'n_tokens_mistral': 482, 'n_tokens_neox': 451, 'n_words': 134}