forked from Ptt-official-app/go-bbs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
90 changed files
with
3,261 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/ptt/.fresh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package api | ||
|
||
import "github.com/PichuChen/go-bbs" | ||
|
||
type RegisterParams struct { | ||
UserID string | ||
Passwd string | ||
IP string | ||
Email string | ||
|
||
Nickname string | ||
Realname string | ||
Career string | ||
Address string | ||
Over18 bool | ||
} | ||
|
||
type RegisterResult struct { | ||
Jwt string | ||
} | ||
|
||
func Register(params interface{}) (interface{}, error) { | ||
registerParams, ok := params.(*RegisterParams) | ||
if !ok { | ||
return nil, ErrInvalidParams | ||
} | ||
|
||
user, err := bbs.Register( | ||
registerParams.UserID, | ||
registerParams.Passwd, | ||
registerParams.IP, | ||
registerParams.Email, | ||
|
||
registerParams.Nickname, | ||
registerParams.Realname, | ||
registerParams.Career, | ||
registerParams.Address, | ||
registerParams.Over18, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
token, err := createToken(user) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
result := &RegisterResult{ | ||
Jwt: token, | ||
} | ||
|
||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.