mirror of
https://github.com/gogs/gogs.git
synced 2026-02-28 09:10:57 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0318db2f9 | ||
|
|
c6058e5ea8 | ||
|
|
4f2f3c2857 | ||
|
|
925ccc2608 | ||
|
|
11f9d738e8 | ||
|
|
63baf76ab2 | ||
|
|
9c3aa6936a | ||
|
|
32c5fa514c | ||
|
|
eaa7d71fc7 | ||
|
|
e1332c5239 |
@@ -5,7 +5,7 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language
|
||||
|
||||

|
||||
|
||||
##### Current version: 0.4.0 Alpha
|
||||
##### Current version: 0.4.2 Alpha
|
||||
|
||||
### NOTICES
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
|
||||
|
||||

|
||||
|
||||
##### 当前版本:0.4.0 Alpha
|
||||
##### 当前版本:0.4.2 Alpha
|
||||
|
||||
## 开发目的
|
||||
|
||||
|
||||
@@ -89,9 +89,11 @@ func runWeb(*cli.Context) {
|
||||
m.Get("/", ignSignIn, routers.Home)
|
||||
m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install)
|
||||
m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost)
|
||||
m.Get("/issues", reqSignIn, user.Issues)
|
||||
m.Get("/pulls", reqSignIn, user.Pulls)
|
||||
m.Get("/stars", reqSignIn, user.Stars)
|
||||
m.Group("", func(r martini.Router) {
|
||||
r.Get("/issues", user.Issues)
|
||||
r.Get("/pulls", user.Pulls)
|
||||
r.Get("/stars", user.Stars)
|
||||
}, reqSignIn)
|
||||
|
||||
m.Group("/api", func(r martini.Router) {
|
||||
m.Group("/v1", func(r martini.Router) {
|
||||
|
||||
@@ -10,6 +10,12 @@ HOST_PORT="YOUR_HOST_PORT" # The port on host, which will be redirected t
|
||||
# apt source, you can select 'nchc'(mirror in Taiwan) or 'aliyun'(best for mainlance China users) according to your network, if you could connect to the official unbunt mirror in a fast speed, just leave it to "".
|
||||
APT_SOURCE=""
|
||||
|
||||
DOCKER_BIN=$(which docker.io || which docker)
|
||||
if [ -z "$DOCKER_BIN" ] ; then
|
||||
echo "Please install docker. You can install docker by running \"wget -qO- https://get.docker.io/ | sh\"."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Replace the database root password in database image Dockerfile.
|
||||
sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/$DB_TYPE/Dockerfile
|
||||
# Replace the database root password in gogits image deploy.sh file.
|
||||
@@ -36,22 +42,22 @@ if [ $MEM_TYPE != "" ]
|
||||
sed -i "${GOGS_BUILD_LINE}s/$/ -tags $MEM_TYPE/" images/gogits/Dockerfile
|
||||
|
||||
cd images/$MEM_TYPE
|
||||
docker build -t gogits/$MEM_TYPE .
|
||||
docker run -d --name $MEM_RUN_NAME gogits/$MEM_TYPE
|
||||
$DOCKER_BIN build -t gogits/$MEM_TYPE .
|
||||
$DOCKER_BIN run -d --name $MEM_RUN_NAME gogits/$MEM_TYPE
|
||||
MEM_LINK=" --link $MEM_RUN_NAME:mem "
|
||||
cd ../../
|
||||
fi
|
||||
|
||||
# Build the database image
|
||||
cd images/$DB_TYPE
|
||||
docker build -t gogits/$DB_TYPE .
|
||||
$DOCKER_BIN build -t gogits/$DB_TYPE .
|
||||
#
|
||||
|
||||
|
||||
## Build the gogits image
|
||||
cd ../gogits
|
||||
|
||||
docker build -t gogits/gogs .
|
||||
$DOCKER_BIN build -t gogits/gogs .
|
||||
|
||||
#sed -i "s#RUN go get -u -tags $MEM_TYPE github.com/gogits/gogs#RUN go get -u github.com/gogits/gogs#g" Dockerfile
|
||||
|
||||
@@ -60,9 +66,9 @@ sed -i "s/ -tags $MEM_TYPE//" Dockerfile
|
||||
|
||||
#
|
||||
## Run MySQL image with name
|
||||
docker run -d --name $DB_RUN_NAME gogits/$DB_TYPE
|
||||
$DOCKER_BIN run -d --name $DB_RUN_NAME gogits/$DB_TYPE
|
||||
#
|
||||
## Run gogits image and link it to the database image
|
||||
echo "Now we have the $DB_TYPE image(running) and gogs image, use the follow command to start gogs service:"
|
||||
echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db $MEM_LINK -p $HOST_PORT:3000 gogits/gogs \033[0m"
|
||||
echo -e "\033[33m $DOCKER_BIN run -i -t --link $DB_RUN_NAME:db $MEM_LINK -p $HOST_PORT:3000 gogits/gogs \033[0m"
|
||||
|
||||
|
||||
@@ -5,9 +5,15 @@ typeset -u MYSQL_ALIAS
|
||||
MYSQL_ALIAS="db"
|
||||
HOST_PORT="3000"
|
||||
|
||||
DOCKER_BIN=$(which docker.io || which docker)
|
||||
if [ -z "$DOCKER_BIN" ] ; then
|
||||
echo "Please install docker. You can install docker by running \"wget -qO- https://get.docker.io/ | sh\"."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Run MySQL image with name
|
||||
docker run -d --name $MYSQL_RUN_NAME gogs/mysql
|
||||
$DOCKER_BIN run -d --name $MYSQL_RUN_NAME gogs/mysql
|
||||
#
|
||||
## Run gogits image and link it to the MySQL image
|
||||
docker run --link $MYSQL_RUN_NAME:$MYSQL_ALIAS -p $HOST_PORT:3000 gogs/gogits
|
||||
$DOCKER_BIN run --link $MYSQL_RUN_NAME:$MYSQL_ALIAS -p $HOST_PORT:3000 gogs/gogits
|
||||
|
||||
|
||||
2
gogs.go
2
gogs.go
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.4.1.0601 Alpha"
|
||||
const APP_VER = "0.4.2.0605 Alpha"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
@@ -771,7 +771,7 @@ type Comment struct {
|
||||
IssueId int64
|
||||
CommitId int64
|
||||
Line int64
|
||||
Content string
|
||||
Content string `xorm:"TEXT"`
|
||||
Created time.Time `xorm:"CREATED"`
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +150,8 @@ func DelLoginSource(source *LoginSource) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// login a user
|
||||
func LoginUser(uname, passwd string) (*User, error) {
|
||||
// UserSignIn validates user name and password.
|
||||
func UserSignIn(uname, passwd string) (*User, error) {
|
||||
var u *User
|
||||
if strings.Contains(uname, "@") {
|
||||
u = &User{Email: uname}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
@@ -30,9 +31,9 @@ import (
|
||||
var (
|
||||
ErrRepoAlreadyExist = errors.New("Repository already exist")
|
||||
ErrRepoNotExist = errors.New("Repository does not exist")
|
||||
ErrRepoFileNotExist = errors.New("Target Repo file does not exist")
|
||||
ErrRepoFileNotExist = errors.New("Repository file does not exist")
|
||||
ErrRepoNameIllegal = errors.New("Repository name contains illegal characters")
|
||||
ErrRepoFileNotLoaded = errors.New("repo file not loaded")
|
||||
ErrRepoFileNotLoaded = errors.New("Repository file not loaded")
|
||||
ErrMirrorNotExist = errors.New("Mirror does not exist")
|
||||
)
|
||||
|
||||
@@ -45,7 +46,7 @@ func getAssetList(prefix string) []string {
|
||||
assets := make([]string, 0, 15)
|
||||
for _, name := range bin.AssetNames() {
|
||||
if strings.HasPrefix(name, prefix) {
|
||||
assets = append(assets, name)
|
||||
assets = append(assets, strings.TrimPrefix(name, prefix+"/"))
|
||||
}
|
||||
}
|
||||
return assets
|
||||
@@ -75,6 +76,8 @@ func LoadRepoConfig() {
|
||||
|
||||
LanguageIgns = typeFiles[0]
|
||||
Licenses = typeFiles[1]
|
||||
sort.Strings(LanguageIgns)
|
||||
sort.Strings(Licenses)
|
||||
}
|
||||
|
||||
func NewRepoContext() {
|
||||
@@ -486,22 +489,40 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
||||
// .gitignore
|
||||
if repoLang != "" {
|
||||
filePath := "conf/gitignore/" + repoLang
|
||||
if com.IsFile(filePath) {
|
||||
if err := com.Copy(filePath,
|
||||
filepath.Join(tmpDir, fileName["gitign"])); err != nil {
|
||||
targetPath := path.Join(tmpDir, fileName["gitign"])
|
||||
data, err := bin.Asset(filePath)
|
||||
if err == nil {
|
||||
if err = ioutil.WriteFile(targetPath, data, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Check custom files.
|
||||
filePath = path.Join(setting.CustomPath, "conf/gitignore", repoLang)
|
||||
if com.IsFile(filePath) {
|
||||
if err := com.Copy(filePath, targetPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LICENSE
|
||||
if license != "" {
|
||||
filePath := "conf/license/" + license
|
||||
if com.IsFile(filePath) {
|
||||
if err := com.Copy(filePath,
|
||||
filepath.Join(tmpDir, fileName["license"])); err != nil {
|
||||
targetPath := path.Join(tmpDir, fileName["license"])
|
||||
data, err := bin.Asset(filePath)
|
||||
if err == nil {
|
||||
if err = ioutil.WriteFile(targetPath, data, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Check custom files.
|
||||
filePath = path.Join(setting.CustomPath, "conf/license", license)
|
||||
if com.IsFile(filePath) {
|
||||
if err := com.Copy(filePath, targetPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ func (user *User) HomeLink() string {
|
||||
return "/user/" + user.Name
|
||||
}
|
||||
|
||||
// AvatarLink returns the user gravatar link.
|
||||
// AvatarLink returns user gravatar link.
|
||||
func (user *User) AvatarLink() string {
|
||||
if setting.DisableGravatar {
|
||||
return "/img/avatar_default.jpg"
|
||||
@@ -121,7 +121,7 @@ func IsEmailUsed(email string) (bool, error) {
|
||||
return orm.Get(&User{Email: email})
|
||||
}
|
||||
|
||||
// return a user salt token
|
||||
// GetUserSalt returns a user salt token
|
||||
func GetUserSalt() string {
|
||||
return base.GetRandomString(10)
|
||||
}
|
||||
@@ -268,17 +268,17 @@ func ChangeUserName(user *User, newUserName string) (err error) {
|
||||
}
|
||||
|
||||
// UpdateUser updates user's information.
|
||||
func UpdateUser(user *User) (err error) {
|
||||
user.LowerName = strings.ToLower(user.Name)
|
||||
func UpdateUser(u *User) (err error) {
|
||||
u.LowerName = strings.ToLower(u.Name)
|
||||
|
||||
if len(user.Location) > 255 {
|
||||
user.Location = user.Location[:255]
|
||||
if len(u.Location) > 255 {
|
||||
u.Location = u.Location[:255]
|
||||
}
|
||||
if len(user.Website) > 255 {
|
||||
user.Website = user.Website[:255]
|
||||
if len(u.Website) > 255 {
|
||||
u.Website = u.Website[:255]
|
||||
}
|
||||
|
||||
_, err = orm.Id(user.Id).AllCols().Update(user)
|
||||
_, err = orm.Id(u.Id).AllCols().Update(u)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -356,17 +356,16 @@ func GetUserByKeyId(keyId int64) (*User, error) {
|
||||
return user, nil
|
||||
}
|
||||
|
||||
// GetUserById returns the user object by given id if exists.
|
||||
// GetUserById returns the user object by given ID if exists.
|
||||
func GetUserById(id int64) (*User, error) {
|
||||
user := new(User)
|
||||
has, err := orm.Id(id).Get(user)
|
||||
u := new(User)
|
||||
has, err := orm.Id(id).Get(u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !has {
|
||||
} else if !has {
|
||||
return nil, ErrUserNotExist
|
||||
}
|
||||
return user, nil
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// GetUserByName returns the user object by given name if exists.
|
||||
|
||||
@@ -19,54 +19,54 @@ import (
|
||||
)
|
||||
|
||||
// SignedInId returns the id of signed in user.
|
||||
func SignedInId(session session.SessionStore) int64 {
|
||||
func SignedInId(sess session.SessionStore) int64 {
|
||||
if !models.HasEngine {
|
||||
return 0
|
||||
}
|
||||
|
||||
userId := session.Get("userId")
|
||||
if userId == nil {
|
||||
uid := sess.Get("userId")
|
||||
if uid == nil {
|
||||
return 0
|
||||
}
|
||||
if s, ok := userId.(int64); ok {
|
||||
if _, err := models.GetUserById(s); err != nil {
|
||||
if id, ok := uid.(int64); ok {
|
||||
if _, err := models.GetUserById(id); err != nil {
|
||||
return 0
|
||||
}
|
||||
return s
|
||||
return id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// SignedInName returns the name of signed in user.
|
||||
func SignedInName(session session.SessionStore) string {
|
||||
userName := session.Get("userName")
|
||||
if userName == nil {
|
||||
func SignedInName(sess session.SessionStore) string {
|
||||
uname := sess.Get("userName")
|
||||
if uname == nil {
|
||||
return ""
|
||||
}
|
||||
if s, ok := userName.(string); ok {
|
||||
if s, ok := uname.(string); ok {
|
||||
return s
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SignedInUser returns the user object of signed user.
|
||||
func SignedInUser(session session.SessionStore) *models.User {
|
||||
id := SignedInId(session)
|
||||
if id <= 0 {
|
||||
func SignedInUser(sess session.SessionStore) *models.User {
|
||||
uid := SignedInId(sess)
|
||||
if uid <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
user, err := models.GetUserById(id)
|
||||
u, err := models.GetUserById(uid)
|
||||
if err != nil {
|
||||
log.Error("user.SignedInUser: %v", err)
|
||||
return nil
|
||||
}
|
||||
return user
|
||||
return u
|
||||
}
|
||||
|
||||
// IsSignedIn check if any user has signed in.
|
||||
func IsSignedIn(session session.SessionStore) bool {
|
||||
return SignedInId(session) > 0
|
||||
func IsSignedIn(sess session.SessionStore) bool {
|
||||
return SignedInId(sess) > 0
|
||||
}
|
||||
|
||||
type FeedsForm struct {
|
||||
|
||||
@@ -26,10 +26,10 @@ func NewMailMessageFrom(To []string, from, subject, body string) Message {
|
||||
|
||||
// Create New mail message use MailFrom and MailUser
|
||||
func NewMailMessage(To []string, subject, body string) Message {
|
||||
return NewMailMessageFrom(To, setting.MailService.User, subject, body)
|
||||
return NewMailMessageFrom(To, setting.MailService.From, subject, body)
|
||||
}
|
||||
|
||||
func GetMailTmplData(user *models.User) map[interface{}]interface{} {
|
||||
func GetMailTmplData(u *models.User) map[interface{}]interface{} {
|
||||
data := make(map[interface{}]interface{}, 10)
|
||||
data["AppName"] = setting.AppName
|
||||
data["AppVer"] = setting.AppVer
|
||||
@@ -37,29 +37,29 @@ func GetMailTmplData(user *models.User) map[interface{}]interface{} {
|
||||
data["AppLogo"] = setting.AppLogo
|
||||
data["ActiveCodeLives"] = setting.Service.ActiveCodeLives / 60
|
||||
data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60
|
||||
if user != nil {
|
||||
data["User"] = user
|
||||
if u != nil {
|
||||
data["User"] = u
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// create a time limit code for user active
|
||||
func CreateUserActiveCode(user *models.User, startInf interface{}) string {
|
||||
func CreateUserActiveCode(u *models.User, startInf interface{}) string {
|
||||
minutes := setting.Service.ActiveCodeLives
|
||||
data := base.ToStr(user.Id) + user.Email + user.LowerName + user.Passwd + user.Rands
|
||||
data := base.ToStr(u.Id) + u.Email + u.LowerName + u.Passwd + u.Rands
|
||||
code := base.CreateTimeLimitCode(data, minutes, startInf)
|
||||
|
||||
// add tail hex username
|
||||
code += hex.EncodeToString([]byte(user.LowerName))
|
||||
code += hex.EncodeToString([]byte(u.LowerName))
|
||||
return code
|
||||
}
|
||||
|
||||
// Send user register mail with active code
|
||||
func SendRegisterMail(r *middleware.Render, user *models.User) {
|
||||
code := CreateUserActiveCode(user, nil)
|
||||
func SendRegisterMail(r *middleware.Render, u *models.User) {
|
||||
code := CreateUserActiveCode(u, nil)
|
||||
subject := "Register success, Welcome"
|
||||
|
||||
data := GetMailTmplData(user)
|
||||
data := GetMailTmplData(u)
|
||||
data["Code"] = code
|
||||
body, err := r.HTMLString("mail/auth/register_success", data)
|
||||
if err != nil {
|
||||
@@ -67,19 +67,19 @@ func SendRegisterMail(r *middleware.Render, user *models.User) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMailMessage([]string{user.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send register mail", user.Id)
|
||||
msg := NewMailMessage([]string{u.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id)
|
||||
|
||||
SendAsync(&msg)
|
||||
}
|
||||
|
||||
// Send email verify active email.
|
||||
func SendActiveMail(r *middleware.Render, user *models.User) {
|
||||
code := CreateUserActiveCode(user, nil)
|
||||
func SendActiveMail(r *middleware.Render, u *models.User) {
|
||||
code := CreateUserActiveCode(u, nil)
|
||||
|
||||
subject := "Verify your e-mail address"
|
||||
|
||||
data := GetMailTmplData(user)
|
||||
data := GetMailTmplData(u)
|
||||
data["Code"] = code
|
||||
body, err := r.HTMLString("mail/auth/active_email", data)
|
||||
if err != nil {
|
||||
@@ -87,19 +87,19 @@ func SendActiveMail(r *middleware.Render, user *models.User) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMailMessage([]string{user.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send active mail", user.Id)
|
||||
msg := NewMailMessage([]string{u.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send active mail", u.Id)
|
||||
|
||||
SendAsync(&msg)
|
||||
}
|
||||
|
||||
// Send reset password email.
|
||||
func SendResetPasswdMail(r *middleware.Render, user *models.User) {
|
||||
code := CreateUserActiveCode(user, nil)
|
||||
func SendResetPasswdMail(r *middleware.Render, u *models.User) {
|
||||
code := CreateUserActiveCode(u, nil)
|
||||
|
||||
subject := "Reset your password"
|
||||
|
||||
data := GetMailTmplData(user)
|
||||
data := GetMailTmplData(u)
|
||||
data["Code"] = code
|
||||
body, err := r.HTMLString("mail/auth/reset_passwd", data)
|
||||
if err != nil {
|
||||
@@ -107,14 +107,14 @@ func SendResetPasswdMail(r *middleware.Render, user *models.User) {
|
||||
return
|
||||
}
|
||||
|
||||
msg := NewMailMessage([]string{user.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send reset password email", user.Id)
|
||||
msg := NewMailMessage([]string{u.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send reset password email", u.Id)
|
||||
|
||||
SendAsync(&msg)
|
||||
}
|
||||
|
||||
// SendIssueNotifyMail sends mail notification of all watchers of repository.
|
||||
func SendIssueNotifyMail(user, owner *models.User, repo *models.Repository, issue *models.Issue) ([]string, error) {
|
||||
func SendIssueNotifyMail(u, owner *models.User, repo *models.Repository, issue *models.Issue) ([]string, error) {
|
||||
ws, err := models.GetWatchers(repo.Id)
|
||||
if err != nil {
|
||||
return nil, errors.New("mail.NotifyWatchers(GetWatchers): " + err.Error())
|
||||
@@ -123,7 +123,7 @@ func SendIssueNotifyMail(user, owner *models.User, repo *models.Repository, issu
|
||||
tos := make([]string, 0, len(ws))
|
||||
for i := range ws {
|
||||
uid := ws[i].UserId
|
||||
if user.Id == uid {
|
||||
if u.Id == uid {
|
||||
continue
|
||||
}
|
||||
u, err := models.GetUserById(uid)
|
||||
@@ -141,14 +141,14 @@ func SendIssueNotifyMail(user, owner *models.User, repo *models.Repository, issu
|
||||
content := fmt.Sprintf("%s<br>-<br> <a href=\"%s%s/%s/issues/%d\">View it on Gogs</a>.",
|
||||
base.RenderSpecialLink([]byte(issue.Content), owner.Name+"/"+repo.Name),
|
||||
setting.AppUrl, owner.Name, repo.Name, issue.Index)
|
||||
msg := NewMailMessageFrom(tos, user.Email, subject, content)
|
||||
msg := NewMailMessageFrom(tos, u.Email, subject, content)
|
||||
msg.Info = fmt.Sprintf("Subject: %s, send issue notify emails", subject)
|
||||
SendAsync(&msg)
|
||||
return tos, nil
|
||||
}
|
||||
|
||||
// SendIssueMentionMail sends mail notification for who are mentioned in issue.
|
||||
func SendIssueMentionMail(r *middleware.Render, user, owner *models.User,
|
||||
func SendIssueMentionMail(r *middleware.Render, u, owner *models.User,
|
||||
repo *models.Repository, issue *models.Issue, tos []string) error {
|
||||
|
||||
if len(tos) == 0 {
|
||||
@@ -166,14 +166,14 @@ func SendIssueMentionMail(r *middleware.Render, user, owner *models.User,
|
||||
return fmt.Errorf("mail.SendIssueMentionMail(fail to render): %v", err)
|
||||
}
|
||||
|
||||
msg := NewMailMessageFrom(tos, user.Email, subject, body)
|
||||
msg := NewMailMessageFrom(tos, u.Email, subject, body)
|
||||
msg.Info = fmt.Sprintf("Subject: %s, send issue mention emails", subject)
|
||||
SendAsync(&msg)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendCollaboratorMail sends mail notification to new collaborator.
|
||||
func SendCollaboratorMail(r *middleware.Render, user, owner *models.User,
|
||||
func SendCollaboratorMail(r *middleware.Render, u, owner *models.User,
|
||||
repo *models.Repository) error {
|
||||
|
||||
subject := fmt.Sprintf("%s added you to %s", owner.Name, repo.Name)
|
||||
@@ -187,8 +187,8 @@ func SendCollaboratorMail(r *middleware.Render, user, owner *models.User,
|
||||
return fmt.Errorf("mail.SendCollaboratorMail(fail to render): %v", err)
|
||||
}
|
||||
|
||||
msg := NewMailMessage([]string{user.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send register mail", user.Id)
|
||||
msg := NewMailMessage([]string{u.Email}, subject, body)
|
||||
msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id)
|
||||
|
||||
SendAsync(&msg)
|
||||
return nil
|
||||
|
||||
@@ -330,6 +330,7 @@ func newSessionService() {
|
||||
type Mailer struct {
|
||||
Name string
|
||||
Host string
|
||||
From string
|
||||
User, Passwd string
|
||||
}
|
||||
|
||||
@@ -363,6 +364,7 @@ func newMailService() {
|
||||
User: Cfg.MustValue("mailer", "USER"),
|
||||
Passwd: Cfg.MustValue("mailer", "PASSWD"),
|
||||
}
|
||||
MailService.From = Cfg.MustValue("mailer", "FROM", MailService.User)
|
||||
log.Info("Mail Service Enabled")
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ package repo
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-martini/martini"
|
||||
|
||||
@@ -72,6 +73,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||
if ctx.Repo.Repository.IsMirror {
|
||||
if form.Interval > 0 {
|
||||
ctx.Repo.Mirror.Interval = form.Interval
|
||||
ctx.Repo.Mirror.NextUpdate = time.Now().Add(time.Duration(form.Interval) * time.Hour)
|
||||
if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
|
||||
log.Error("setting.SettingPost(UpdateMirror): %v", err)
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ func SignIn(ctx *middleware.Context) {
|
||||
}
|
||||
|
||||
// Check auto-login.
|
||||
userName := ctx.GetCookie(setting.CookieUserName)
|
||||
if len(userName) == 0 {
|
||||
uname := ctx.GetCookie(setting.CookieUserName)
|
||||
if len(uname) == 0 {
|
||||
ctx.HTML(200, "user/signin")
|
||||
return
|
||||
}
|
||||
@@ -41,14 +41,14 @@ func SignIn(ctx *middleware.Context) {
|
||||
isSucceed := false
|
||||
defer func() {
|
||||
if !isSucceed {
|
||||
log.Trace("user.SignIn(auto-login cookie cleared): %s", userName)
|
||||
log.Trace("user.SignIn(auto-login cookie cleared): %s", uname)
|
||||
ctx.SetCookie(setting.CookieUserName, "", -1)
|
||||
ctx.SetCookie(setting.CookieRememberName, "", -1)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
user, err := models.GetUserByName(userName)
|
||||
user, err := models.GetUserByName(uname)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "user.SignIn(GetUserByName)", err)
|
||||
return
|
||||
@@ -90,7 +90,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||
return
|
||||
}
|
||||
|
||||
user, err := models.LoginUser(form.UserName, form.Password)
|
||||
user, err := models.UserSignIn(form.UserName, form.Password)
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
log.Trace("%s Log in failed: %s", ctx.Req.RequestURI, form.UserName)
|
||||
@@ -98,7 +98,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Handle(500, "user.SignIn", err)
|
||||
ctx.Handle(500, "user.SignInPost(UserSignIn)", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -220,17 +220,18 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||
if u, err = models.RegisterUser(u); err != nil {
|
||||
switch err {
|
||||
case models.ErrUserAlreadyExist:
|
||||
ctx.Data["Err_UserName"] = true
|
||||
ctx.RenderWithErr("Username has been already taken", "user/signup", &form)
|
||||
case models.ErrEmailAlreadyUsed:
|
||||
ctx.Data["Err_Email"] = true
|
||||
ctx.RenderWithErr("E-mail address has been already used", "user/signup", &form)
|
||||
case models.ErrUserNameIllegal:
|
||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "user/signup", &form)
|
||||
default:
|
||||
ctx.Handle(500, "user.SignUp(RegisterUser)", err)
|
||||
ctx.Handle(500, "user.SignUpPost(RegisterUser)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
log.Trace("%s User created: %s", ctx.Req.RequestURI, form.UserName)
|
||||
|
||||
// Bind social account.
|
||||
@@ -256,6 +257,7 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Redirect("/user/login")
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.4.1.0601 Alpha
|
||||
0.4.2.0605 Alpha
|
||||
@@ -71,21 +71,21 @@
|
||||
<div class="form-group {{if .Err_Attributes}}has-error has-feedback{{end}}">
|
||||
<label class="col-md-3 control-label">Search Attributes: </label>
|
||||
<div class="col-md-7">
|
||||
<input name="attributes" class="form-control" placeholder="Type search attributes" value="{{.Source.LDAP.Attributes}}" required="required">
|
||||
<input name="attributes" class="form-control" placeholder="Type search attributes" value="{{.Source.LDAP.Attributes}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group {{if .Err_Filter}}has-error has-feedback{{end}}">
|
||||
<label class="col-md-3 control-label">Search Filter: </label>
|
||||
<div class="col-md-7">
|
||||
<input name="filter" class="form-control" placeholder="Type search filter" value="{{.Source.LDAP.Filter}}" required="required">
|
||||
<input name="filter" class="form-control" placeholder="Type search filter" value="{{.Source.LDAP.Filter}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group {{if .Err_MsAdSA}}has-error has-feedback{{end}}">
|
||||
<label class="col-md-3 control-label">Ms Ad SA: </label>
|
||||
<div class="col-md-7">
|
||||
<input name="ms_ad_sa" class="form-control" placeholder="Type Ms Ad SA" value="{{.Source.LDAP.MsAdSAFormat}}" required="required">
|
||||
<input name="ms_ad_sa" class="form-control" placeholder="Type Ms Ad SA" value="{{.Source.LDAP.MsAdSAFormat}}">
|
||||
</div>
|
||||
</div>
|
||||
{{else if eq $type 3}}
|
||||
|
||||
Reference in New Issue
Block a user