Skip to content

Commit

Permalink
fix: bind account
Browse files Browse the repository at this point in the history
  • Loading branch information
LiusCraft committed Feb 19, 2024
1 parent c3804aa commit 6ecd540
Show file tree
Hide file tree
Showing 8 changed files with 1,079 additions and 1,439 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ go.work
# gop_autogen.go
dist/
node_modules/
.vscode/
82 changes: 53 additions & 29 deletions cmd/gopcomm/community_yap.gox
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ get "/p/:id", ctx => {
"Title": article.Title,
"Content": article.Content,
// "HtmlUrl": article.HtmlUrl,
"Tags": article.Tags,
"Cover": article.Cover,
"Mtime": article.Mtime.Format(layoutUS),
"Author": article.User,
"Tags": article.Tags,
"Cover": article.Cover,
"Mtime": article.Mtime.Format(layoutUS),
"Author": article.User,
// "User": article.User,
}
}
Expand Down Expand Up @@ -120,7 +120,24 @@ get "/user/:id", ctx => {
"UserId": user.Id,
}
}
get "/userUnlink", ctx => {
pv := ctx.param("pv")
switch pv {
case "Twitter":
case "Facebook":
case "Github":
case "WeChat":
default:
http.Redirect(ctx.ResponseWriter, ctx.Request, "/userEdit", http.StatusTemporaryRedirect)
}
token, err := core.GetToken(ctx)
if err == nil {
http.Redirect(ctx.ResponseWriter, ctx.Request, "/userEdit", http.StatusTemporaryRedirect)
}

community.UnLink(token.Value, pv)
http.Redirect(ctx.ResponseWriter, ctx.Request, "/userEdit", http.StatusTemporaryRedirect)
}
get "/userEdit", ctx => {
var user *core.User
token, err := core.GetToken(ctx)
Expand All @@ -134,8 +151,15 @@ get "/userEdit", ctx => {
if err != nil {
http.Redirect(ctx.ResponseWriter, ctx.Request, "/error", http.StatusTemporaryRedirect)
}
appInfo, err := community.GetApplicationInfo()
if err != nil {
http.Redirect(ctx.ResponseWriter, ctx.Request, "/error", http.StatusTemporaryRedirect)
}
appInfoStr, _ := json.Marshal(*appInfo)
ctx.yap "user_edit", {
"User": user,
"User": user,
"Application": string(appInfoStr),
"Binds": community.GetAccountBinds(token.Value),
}
}

Expand All @@ -149,7 +173,7 @@ get "/add", ctx => {
}
}
ctx.yap "edit", {
"User": user,
"User": user,
}
}

Expand Down Expand Up @@ -347,15 +371,15 @@ post "/commit", ctx => {
// get user id
token, err := core.GetToken(ctx)
if err != nil {
xLog.Info("token",err)
xLog.Info("token", err)
ctx.json {
"code": 0,
"err": "no token",
}
}
uid, err := community.ParseJwtToken(token.Value)
if err != nil {
xLog.Info("uid",err)
xLog.Info("uid", err)
ctx.json {
"code": 0,
"err": err.Error(),
Expand All @@ -367,11 +391,11 @@ post "/commit", ctx => {
ID: id,
Title: ctx.param("title"),
UId: uid,
Cover: ctx.param("cover"),
Cover: ctx.param("cover"),
Tags: ctx.param("tags"),
Abstract: ctx.param("abstract"),
},
Content: mdData,
Content: mdData,
TransContent: transData,
}
id, _ = community.PutArticle(todo, uid, article)
Expand Down Expand Up @@ -450,26 +474,26 @@ get "/getMediaUrl/:id", ctx => {
get "/getVideoAndSubtitle/:id", ctx => {
id := ctx.param("id")
fileKey, err := community.GetMediaUrl(todo, id)
m:=make(map[string]string,2)
format,err:=community.GetMediaType(todo,id)
if err!=nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
m := make(map[string]string, 2)
format, err := community.GetMediaType(todo, id)
if err != nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
}
if format == "video/mp4" {
subtitle,err:=community.GetVideoSubtitle(todo,id)
if err!=nil{
if err != nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
}
return
}
m["subtitle"] = domain+subtitle
subtitle, err := community.GetVideoSubtitle(todo, id)
if err != nil {
if err != nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
}
return
}
m["subtitle"] = domain + subtitle
}
htmlUrl := fmt.Sprintf("%s%s", domain, fileKey)
if err != nil {
Expand Down Expand Up @@ -539,7 +563,7 @@ get "/callback", ctx => {
origin_path := ctx.URL.Query().Get("origin_path")
unurl, err := url.QueryUnescape(origin_path)
if err != nil {
xLog.Info("Unurl error",err)
xLog.Info("Unurl error", err)
unurl = "/"
}

Expand Down
Loading

0 comments on commit 6ecd540

Please sign in to comment.