Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create code style workflow #10

Merged
merged 4 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Style

on:
push:
branches:
- main
pull_request:
paths:
- '**/*.rs'

env:
CARGO_TERM_COLOR: always

jobs:
lint:
name: Clippy
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install toolchain
run: |
rustup install stable
rustup component add clippy

- name: Run clippy
run: cargo clippy --workspace --tests -- -D warnings

format:
name: Rustfmt
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install toolchain
run: |
rustup install stable
rustup component add rustfmt

- name: Run rustfmt
run: cargo fmt --check --all
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic

## [Unreleased]

No changes have been made since the last release.
### Added
- Create code style workflow ([#10](https://github.com/ristekoss/rust-sso-ui-jwt/pull/10)) ([@nayyara-airlangga])

### Fixed
- Fix `actix-web-example` to match the code standards ([#10](https://github.com/ristekoss/rust-sso-ui-jwt/pull/10)) ([@nayyara-airlangga])


## [v0.2.0] - 2022-07-30
Expand Down
6 changes: 3 additions & 3 deletions examples/actix-web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ struct TokenRes {

async fn login(config: web::Data<SSOJWTConfig>, query: web::Query<LoginQuery>) -> HttpResponse {
if let Some(ticket) = &query.ticket {
let res = validate_ticket(&**config, &ticket).await;
let res = validate_ticket(&**config, ticket).await;

match res {
Ok(res) => {
let token = create_token(&config, TokenType::AccessToken, res.clone()).unwrap();
let token = create_token(&config, TokenType::AccessToken, res).unwrap();

let creds = TokenRes { token };
HttpResponse::Ok().json(creds)
Expand Down Expand Up @@ -58,7 +58,7 @@ async fn get_self(config: web::Data<SSOJWTConfig>, req: HttpRequest) -> HttpResp
let token = header_vec.get(1);

if let Some(token) = token {
match decode_token(&**config, TokenType::AccessToken, &token) {
match decode_token(&**config, TokenType::AccessToken, token) {
Ok(data) => HttpResponse::Ok().json(SSOUser::from(data.claims)),
Err(err) => HttpResponse::Unauthorized().body(err.to_string()),
}
Expand Down