Yoginth 7 years ago
parent
commit
8d8f9101d7
1 changed files with 10 additions and 0 deletions
  1. 10 0
      routes/user/profile.go

+ 10 - 0
routes/user/profile.go

@@ -3,6 +3,7 @@ package user
 import (
 	"fmt"
 	"gitote/gitote/models"
+	"gitote/gitote/models/errors"
 	"gitote/gitote/pkg/context"
 	"gitote/gitote/pkg/setting"
 	"gitote/gitote/pkg/tool"
@@ -122,3 +123,12 @@ func Action(c *context.Context, puser *context.ParamsUser) {
 	}
 	c.Redirect(redirectTo)
 }
+
+func GetUserByName(c *context.Context, name string) *models.User {
+	user, err := models.GetUserByName(name)
+	if err != nil {
+		c.NotFoundOrServerError("GetUserByName", errors.IsUserNotExist, err)
+		return nil
+	}
+	return user
+}